Модераторы: bsa
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> throw с перегрузкой операторов, предусмотрение экстренных случаев 
V
    Опции темы
Killer_13
Дата 25.10.2010, 21:08 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 740
Регистрация: 12.1.2008
Где: Germany

Репутация: 1
Всего: 1



Суть задания в том, чтоб делать +,-,*,/ с рациональными числами и предусмотреть экстренные случаи типо деление на нуль и так д...
Вот каков вопрос как мне проверять эти экстренные случаи 
Я сначала создал функцию, но как только находит что-то похожее, то выбрасывает соответственно сразу из программы.

Куда мне всунуть эту проверку, чтоб не выбрасывало из программы

*.h
Код

struct RationaleZahl {
  char Vorzeichen;
  unsigned int  Zaehler, Nenner;
};


main.cpp
Код

void test7() {
  // Test ...
  cout << "Testprogramm 7" << endl;
  RationaleZahl a = {'+', 1, 3}; // +1/3
    RationaleZahl b = {'*', 1, 4}; // +1/4
    RationaleZahl c = {'+', 4, 9}; // +4/9
    RationaleZahl d = {'+', 3, 10}; // +3/10
    RationaleZahl e = {'-', 1, 3}; // -1/3
    RationaleZahl f = {'-', 1, 4}; // -1/4
    RationaleZahl g = {'-', 4, 9}; // -4/9
    RationaleZahl h = {'-', 3, 10}; // -3/10
    cout << a << '*' << b << '=' << a * b << endl;
    cout << c << '/' << d << '=' << c / d << endl;
    cout << b << '*' << a << '=' << b * a << endl;
    cout << d << '/' << c << '=' << d / c << endl;
    cout << h << '*' << b << '=' << h * b << endl;
    cout << f << '/' << d << '=' << f / d << endl;
    cout << h << '*' << g << '=' << h * g << endl;
    cout << g << '/' << h << '=' << g / h << endl;
}
void test8() {
  // Test ...
  cout << "Testprogramm 8" << endl;
    RationaleZahl a = {'+', 1, 0}; // +1/0
    RationaleZahl b = {'-', 0, 3}; // -0/3
    RationaleZahl c = {'+', 0, 0}; // +0/0
    RationaleZahl d = {'-', 4, 0}; // -4/0
    //cout << a << '/' << c << '=' << a / c << endl;
    cout << b << '/' << c << '=' << b / c << endl;
    cout << c << '*' << d << '=' << c * d << endl;
    cout << a << '*' << c << '=' << a * c << endl;
    cout << c << '*' << c << '=' << c * c << endl;
    cout << c << '+' << c << '=' << c + c << endl;

}


int main() {
  void (*testfkts[])(void) = {test1, test2, test3, test4,
                              test5, test6, test7, test8};
  for (int i=0;i<sizeof(testfkts)/sizeof(void (*)(void));i++) {
    try {
      (*testfkts[i])();
    } catch (UnendlichDurchUnendlich) {
      cout << "--> Ausnahme: Unendlich durch Unendlich" << endl;
    } catch (NullDurchNull) {
      cout << "--> Ausnahme: 0 durch 0" << endl;
    } catch (NullMalUnendlich) {
      cout << "--> Ausnahme: 0 mal unendlich" << endl;
    } catch (MinusUnendlichUndPlusUnendlich) {
      cout << "--> Ausnahme: -unendlich + +unendlich" << endl;
    } catch (KeineZahl) {
      cout << "--> Ausnahme: Keine Zahl" << endl;
    } catch (FalschesVorzeichen) {
      cout << "--> Ausnahme: FalschesVorzeichen" << endl;
    } catch (...) {
      cout << "--> Ausnahme: Unbekannte Ausnahme" << endl;
    }
  }
}

funktionen.cpp

Код

RationaleZahl & operator -(const RationaleZahl &l, const RationaleZahl &r) {

    event('-', l, r);

    static RationaleZahl result;
    double x3 = static_cast<double> (l.Zaehler) / l.Nenner,
            x4 = static_cast<double> (r.Zaehler) / r.Nenner;

    if ((l.Vorzeichen == '-') && (r.Vorzeichen == '-')) {
        if (x3 < x4)
            result = fallZeichen(result, l, r, 4);
        else
            result = fallZeichen(result, l, r, 3);
    } else if ((l.Vorzeichen == '+') && (r.Vorzeichen == '-'))
        result = fallZeichen(result, l, r, 1);
    else if ((l.Vorzeichen == '+') && (r.Vorzeichen == '+'))
        if (x3 < x4)
            result = fallZeichen(result, l, r, 5);
        else
            result = fallZeichen(result, l, r, 3);
    else if ((l.Vorzeichen == '-') && (r.Vorzeichen == '+'))
        result = fallZeichen(result, l, r, 1);

    reduce(result);
    return result;
}

//-----------------------------------------------------------------------

RationaleZahl & operator *(const RationaleZahl &l, const RationaleZahl &r) {

    event('*', l, r);

    static RationaleZahl result;

    if ((l.Vorzeichen == '-' && r.Vorzeichen == '-') || (l.Vorzeichen == '+' && r.Vorzeichen == '+'))
        result.Vorzeichen = '+';
    else
        result.Vorzeichen = '-';

    result.Nenner = l.Nenner * r.Nenner;
    result.Zaehler = l.Zaehler * r.Zaehler;

    reduce(result);
    return result;
}

void event(char symbol, const RationaleZahl &l, const RationaleZahl &r) {

    if (l.Zaehler == 0 && l.Nenner == 0) throw NullDurchNull();
    if (r.Zaehler == 0 && r.Nenner == 0) throw NullDurchNull();

    if (l.Vorzeichen != '-' && l.Vorzeichen != '+') throw FalschesVorzeichen();
    if (r.Vorzeichen != '-' && r.Vorzeichen != '+') throw FalschesVorzeichen();

    if (symbol == '-' || symbol == '+')
        if (l.Nenner == 0 || r.Nenner == 0)
            throw MinusUnendlichUndPlusUnendlich();

    if (symbol == 0)
        if ((l.Zaehler == 0 && r.Nenner == 0) || (l.Nenner == 0 && r.Zaehler == 0))
            throw NullMalUnendlich();

    if (symbol == '/') {
        if (l.Zaehler == 0 && r.Zaehler == 0)
            throw NullDurchNull();
        if (l.Zaehler != 0 && l.Nenner == 0 && r.Zaehler != 0 && r.Nenner == 0)
            throw UnendlichDurchUnendlich();
    }

    if (symbol == '*') {
        if ((l.Zaehler == 0 || l.Nenner == 0)&&(r.Zaehler == 0 || r.Nenner == 0))
            throw KeineZahl();
    }
}


Пасиб

PM MAIL   Вверх
vnf
Дата 25.10.2010, 21:30 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 51
Регистрация: 9.2.2008

Репутация: нет
Всего: 1



На первый взгляд всё правильно написано.
Компилятор какой?  Может неправильные флаги компиляции?
Приведите объявление исключений UnendlichDurchUnendlich и остальных, может там что не  так. Хотя по идее catch (...) должен всё ловить. Под отладчиком смотрели как исключение обрабатываются?
PM MAIL   Вверх
Killer_13
Дата 25.10.2010, 21:37 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 740
Регистрация: 12.1.2008
Где: Germany

Репутация: 1
Всего: 1



Нет больше ничего, просто печатает сообщение и выбрасывает с функции, а должно проходить всю функцию.. :( Где зарыто?
Мне препод сегодня сказал, что вот так с функцией работать не будет, а как по другому сделать, что то не доганяю.
Повставлял отдельные строки из функции евент в перегрузку операторов, вообще компилироваться не хотело

Вот что на выходе.


Присоединённый файл ( Кол-во скачиваний: 10 )
Присоединённый файл  1.jpg 89,51 Kb
PM MAIL   Вверх
vnf
Дата 25.10.2010, 21:56 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 51
Регистрация: 9.2.2008

Репутация: нет
Всего: 1



Когда бросается исключение (throw) весь код до catch пропускается. В вашем случае после 
исключения в строке cout << b << '/' << c << '=' << b / c << endl; следующие в этой функции выполняться не будут, управление передастся на соответствующий catch.

Проще всего написать try catch внутри event.
PM MAIL   Вверх
djamshud
Дата 25.10.2010, 22:14 (ссылка) |    (голосов:1) Загрузка ... Загрузка ... Быстрая цитата Цитата


Пердупержденный
***


Профиль
Группа: Завсегдатай
Сообщений: 1655
Регистрация: 23.11.2009

Репутация: 4
Всего: 39



За использование фошистского в именах идентификаторов зачет. Код становится сказачно непонятным:).

Код

#include<stdio.h>

enum shit_t{div_0=1};

class _int{
public:
int value;
_int(int v):value(v){}

_int operator/(_int v){
if(v.value==0)throw div_0;
return this->value/v.value;}
};

int main(){
_int a=4,b=1;
try{
printf("%d\n",(a/b).value);}
catch(shit_t code){
if(code==div_0)printf("Shit happens! Division by zero.\n");}
return 0;}


Общая идея такова.

Это сообщение отредактировал(а) djamshud - 25.10.2010, 22:14


--------------------
'Cuz I never walk away from what I know is right
Alice Cooper - Freedom
PM   Вверх
Killer_13
Дата 25.10.2010, 22:34 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 740
Регистрация: 12.1.2008
Где: Germany

Репутация: 1
Всего: 1



djamshud - Че - т сложновато написано. Но попробую разобрать, неохота уже сегодня половину задачи переделывать
:(
А фашистский приходится использовать так как учусь здесь. smile

Хочется как можно лучше подправить и все. Вот такая у меня структура если целиком - может кому пригодиться, все считает четко. smile

Код

#include <iostream>
#include "RationaleZahl.h"

using namespace std;

void test1() {
  // Test der Arithmetik
  cout << "Testprogramm 1:" << endl;
  RationaleZahl a = {'+',4,7}; // +4/7
  RationaleZahl b = {'-',1,4}; // -1/4
  RationaleZahl c = {'+',5,6}; // +5/6
  cout << b << '+' << b << '=' << b+b << endl;
  cout << b << '+' << c << '='<< b+c << endl;
  cout << c << '+' << b << '='<< c+b << endl;
  cout << b << '-' << c << '='<< b-c << endl;
  cout << "a*c = "<< a*c << endl;
  cout << "b/a = "<< b/a << endl;
}

void test2() {
    // Test unbekannte Ausnahme
    //  cout <<"\n\n"<< "Testprogramm 2:"
    //       << "  int-Ausnahme. (Sollte als unbekannte Ausnahme gefangen werden)"
    //       <<"\n\n"<< endl;
    throw int(10);
}

void test3() {
    cout << "Testprogramm 3!!:" << endl;
    RationaleZahl a = {'+', 1, 3}; // +1/3
    RationaleZahl b = {'+', 1, 4}; // +1/4
    RationaleZahl c = {'+', 2, 7}; // +2/7
    RationaleZahl d = {'+', 3, 5}; // +3/5
    RationaleZahl e = {'-', 1, 3}; // -1/3
    RationaleZahl f = {'-', 1, 4}; // -1/4
    RationaleZahl g = {'-', 2, 7}; // -2/7
    RationaleZahl h = {'-', 3, 5}; // -3/5
    cout << a << '+' << b << '=' << a + b << endl;
    cout << c << '+' << d << '=' << c + d << endl;
    cout << f << '+' << a << '=' << f + a << endl;
    cout << e << '+' << b << '=' << e + b << endl;
    cout << g << '+' << d << '=' << g + d << endl;
    cout << h << '+' << c << '=' << h + c << endl;
    cout << f << '+' << e << '=' << f + e << endl;
    cout << e << '+' << f << '=' << e + f << endl;
    cout << h << '+' << c << '=' << h + c << endl;
    cout << g << '+' << h << '=' << g + h << endl;
    cout << b << '+' << e << '=' << b + e << endl;
    cout << a << '+' << f << '=' << a + f << endl;
    cout << c << '+' << h << '=' << c + h << endl;
    cout << d << '+' << g << '=' << d + g << endl;
}

void test4() {
    // Test ...
    cout << "Testprogramm 4" << endl;
}

void test5() {
    cout << "Testprogramm 5:" << endl;
    RationaleZahl a = {'+', 1, 3}; // +1/3
    RationaleZahl b = {'+', 1, 4}; // +1/4
    RationaleZahl c = {'+', 4, 9}; // +4/9
    RationaleZahl d = {'+', 3, 10}; // +3/10
    RationaleZahl e = {'-', 1, 3}; // -1/3
    RationaleZahl f = {'-', 1, 4}; // -1/4
    RationaleZahl g = {'-', 4, 9}; // -4/9
    RationaleZahl h = {'-', 3, 10}; // -3/10
    cout << a << '-' << b << '=' << a - b << endl;
    cout << c << '-' << d << '=' << c - d << endl;
    cout << b << '-' << a << '=' << b - a << endl;
    cout << d << '-' << c << '=' << d - c << endl;
    cout << h << '-' << b << '=' << h - b << endl;
    cout << f << '-' << d << '=' << f - d << endl;
    cout << h << '-' << g << '=' << h - g << endl;
    cout << g << '-' << h << '=' << g - h << endl;
}

void test6() {
  // Test ...
  cout << "Testprogramm 6" << endl;
}
void test7() {
  // Test ...
  cout << "Testprogramm 7" << endl;
  RationaleZahl a = {'+', 1, 3}; // +1/3
    RationaleZahl b = {'*', 1, 4}; // +1/4
    RationaleZahl c = {'+', 4, 9}; // +4/9
    RationaleZahl d = {'+', 3, 10}; // +3/10
    RationaleZahl e = {'-', 1, 3}; // -1/3
    RationaleZahl f = {'-', 1, 4}; // -1/4
    RationaleZahl g = {'-', 4, 9}; // -4/9
    RationaleZahl h = {'-', 3, 10}; // -3/10
    cout << a << '*' << b << '=' << a * b << endl;
    cout << c << '/' << d << '=' << c / d << endl;
    cout << b << '*' << a << '=' << b * a << endl;
    cout << d << '/' << c << '=' << d / c << endl;
    cout << h << '*' << b << '=' << h * b << endl;
    cout << f << '/' << d << '=' << f / d << endl;
    cout << h << '*' << g << '=' << h * g << endl;
    cout << g << '/' << h << '=' << g / h << endl;
}
void test8() {
  // Test ...
  cout << "Testprogramm 8" << endl;
    RationaleZahl a = {'+', 1, 0}; // +1/0
    RationaleZahl b = {'-', 0, 3}; // -0/3
    RationaleZahl c = {'+', 0, 0}; // +0/0
    RationaleZahl d = {'-', 4, 0}; // -4/0
    //cout << a << '/' << c << '=' << a / c << endl;
    cout << b << '/' << c << '=' << b / c << endl;
    cout << c << '*' << d << '=' << c * d << endl;
    cout << a << '*' << c << '=' << a * c << endl;
    cout << c << '*' << c << '=' << c * c << endl;
    cout << c << '+' << c << '=' << c + c << endl;

}

int main() {
  void (*testfkts[])(void) = {test1, test2, test3, test4,
                              test5, test6, test7, test8};
  for (int i=0;i<sizeof(testfkts)/sizeof(void (*)(void));i++) {
    try {
      (*testfkts[i])();
    } catch (UnendlichDurchUnendlich) {
      cout << "--> Ausnahme: Unendlich durch Unendlich" << endl;
    } catch (NullDurchNull) {
      cout << "--> Ausnahme: 0 durch 0" << endl;
    } catch (NullMalUnendlich) {
      cout << "--> Ausnahme: 0 mal unendlich" << endl;
    } catch (MinusUnendlichUndPlusUnendlich) {
      cout << "--> Ausnahme: -unendlich + +unendlich" << endl;
    } catch (KeineZahl) {
      cout << "--> Ausnahme: Keine Zahl" << endl;
    } catch (FalschesVorzeichen) {
      cout << "--> Ausnahme: FalschesVorzeichen" << endl;
    } catch (...) {
      cout << "--> Ausnahme: Unbekannte Ausnahme" << endl;
    }
  }
}




Код

#include <iostream>

using namespace std;

struct UnendlichDurchUnendlich{};
struct NullDurchNull{};
struct NullMalUnendlich{};
struct MinusUnendlichUndPlusUnendlich{};
struct KeineZahl{};
struct FalschesVorzeichen{};
struct UeberlaufImZaehler{};           // Freiwillig
struct UeberlaufImNenner{};            // Freiwillig
struct UeberlaufImZaehlerUndNenner{};  // Freiwillig

//
// Vereinbarung des Benutzerdefinierten Datentyps "Rationale Zahl"
//
struct RationaleZahl {
  char Vorzeichen;
  unsigned int  Zaehler, Nenner;
};

RationaleZahl &operator +(const RationaleZahl &l, const RationaleZahl &r);
RationaleZahl &operator -(const RationaleZahl &l, const RationaleZahl &r);
RationaleZahl &operator *(const RationaleZahl &l, const RationaleZahl &r);
RationaleZahl &operator /(const RationaleZahl &l, const RationaleZahl &r);

ostream &operator << (ostream & o, const RationaleZahl &r); // benoetigt <iostream>

void event (char, const RationaleZahl&, const RationaleZahl&);
void reduce(RationaleZahl&);
unsigned int ggT(unsigned int, unsigned int);
RationaleZahl& fallZeichen(RationaleZahl&, const RationaleZahl&, const RationaleZahl&,int);




Код

#include <iostream>
#include "RationaleZahl.h"

using namespace std;

RationaleZahl & operator +(const RationaleZahl &l, const RationaleZahl &r) {

    event('+', l, r);

    static RationaleZahl result;
    double x1 = static_cast<double> (l.Zaehler) / l.Nenner,
            x2 = static_cast<double> (r.Zaehler) / r.Nenner;

    if (l.Vorzeichen == r.Vorzeichen) {
        result = fallZeichen(result, l, r, 1);
    } else if ((l.Vorzeichen == '+') && (r.Vorzeichen == '-')) {
        if (x1 < x2)
            result = fallZeichen(result, l, r, 2);
        else
            result = fallZeichen(result, l, r, 3);

    } else if ((l.Vorzeichen == '-') && (r.Vorzeichen == '+')) {
        if (x1 < x2)
            result = fallZeichen(result, l, r, 2);
        else
            result = fallZeichen(result, l, r, 3);
    }

    reduce(result);
    return result;
}

//-----------------------------------------------------------------------

RationaleZahl & operator -(const RationaleZahl &l, const RationaleZahl &r) {

    event('-', l, r);

    static RationaleZahl result;
    double x3 = static_cast<double> (l.Zaehler) / l.Nenner,
            x4 = static_cast<double> (r.Zaehler) / r.Nenner;

    if ((l.Vorzeichen == '-') && (r.Vorzeichen == '-')) {
        if (x3 < x4)
            result = fallZeichen(result, l, r, 4);
        else
            result = fallZeichen(result, l, r, 3);
    } else if ((l.Vorzeichen == '+') && (r.Vorzeichen == '-'))
        result = fallZeichen(result, l, r, 1);
    else if ((l.Vorzeichen == '+') && (r.Vorzeichen == '+'))
        if (x3 < x4)
            result = fallZeichen(result, l, r, 5);
        else
            result = fallZeichen(result, l, r, 3);
    else if ((l.Vorzeichen == '-') && (r.Vorzeichen == '+'))
        result = fallZeichen(result, l, r, 1);

    reduce(result);
    return result;
}

//-----------------------------------------------------------------------

RationaleZahl & operator *(const RationaleZahl &l, const RationaleZahl &r) {

    event('*', l, r);

    static RationaleZahl result;

    if ((l.Zaehler == 0 || l.Nenner == 0)&&(r.Zaehler == 0 || r.Nenner == 0))
            throw KeineZahl();

    if ((l.Vorzeichen == '-' && r.Vorzeichen == '-') || (l.Vorzeichen == '+' && r.Vorzeichen == '+'))
        result.Vorzeichen = '+';
    else
        result.Vorzeichen = '-';

    result.Nenner = l.Nenner * r.Nenner;
    result.Zaehler = l.Zaehler * r.Zaehler;

    reduce(result);
    return result;
}

//-----------------------------------------------------------------------

RationaleZahl & operator /(const RationaleZahl &l, const RationaleZahl &r) {

    event('*', l, r);

    static RationaleZahl result;

    if (l.Zaehler == 0 && r.Zaehler == 0)
        throw NullDurchNull();
    if (l.Zaehler != 0 && l.Nenner == 0 && r.Zaehler != 0 && r.Nenner == 0)
        throw UnendlichDurchUnendlich();

    if ((l.Vorzeichen == '-' && r.Vorzeichen == '-') || (l.Vorzeichen == '+' && r.Vorzeichen == '+'))
        result.Vorzeichen = '+';
    else
        result.Vorzeichen = '-';

    result.Nenner = l.Nenner * r.Zaehler;
    result.Zaehler = l.Zaehler * r.Nenner;

    reduce(result);
    return result;
}

//-----------------------------------------------------------------------

ostream & operator <<(ostream & o, const RationaleZahl &r) {

    if (r.Zaehler == 0)
        o << 0 << ')';
    else if (r.Nenner == 0)
        o << r.Vorzeichen << "Unendlich";
    else
        o << '(' << r.Vorzeichen << r.Zaehler << '/' << r.Nenner << ')';

    return o;
}




Код

#include "RationaleZahl.h"

RationaleZahl& fallZeichen(RationaleZahl &result, const RationaleZahl &l, const RationaleZahl &r, int boo) {

    unsigned int n1, n2;

    n1 = l.Nenner / ggT(l.Nenner, r.Nenner);
    n2 = r.Nenner / ggT(l.Nenner, r.Nenner);
    result.Nenner = n1 * n2 * ggT(l.Nenner, r.Nenner);

    switch (boo) {
        case 1:
            result.Zaehler = l.Zaehler * n2 + r.Zaehler*n1;
            result.Vorzeichen = l.Vorzeichen;
            return result;
        case 2:
            result.Zaehler = r.Zaehler * n1 - l.Zaehler * n2;
            result.Vorzeichen = r.Vorzeichen;
            return result;
        case 3:
            result.Zaehler = l.Zaehler * n2 - r.Zaehler * n1;
            result.Vorzeichen = l.Vorzeichen;
            return result;
        case 4:
            result.Zaehler = r.Zaehler * n1 - l.Zaehler * n2;
            result.Vorzeichen = '+';
            return result;
        case 5:
            result.Zaehler = r.Zaehler * n1 - l.Zaehler * n2;
            result.Vorzeichen = '-';
            return result;
    }
}

//-----------------------------------------------------------------------

void reduce(RationaleZahl &res) {

    unsigned int ggT_result;

    ggT_result = ggT(res.Zaehler, res.Nenner);

    res.Zaehler = res.Zaehler / ggT_result;
    res.Nenner = res.Nenner / ggT_result;
}

//-----------------------------------------------------------------------

unsigned int ggT(unsigned int z, unsigned int n) {

    unsigned int r, d;

    if (n != 0) {
        r = z % n;
        d = ggT(n, r);
        return d;
    } else
        return z;
}

//-----------------------------------------------------------------------

void event(char symbol, const RationaleZahl &l, const RationaleZahl &r) {

    if (l.Zaehler == 0 && l.Nenner == 0) throw NullDurchNull();
    if (r.Zaehler == 0 && r.Nenner == 0) throw NullDurchNull();

    if (l.Vorzeichen != '-' && l.Vorzeichen != '+') throw FalschesVorzeichen();
    if (r.Vorzeichen != '-' && r.Vorzeichen != '+') throw FalschesVorzeichen();

    if (symbol == '-' || symbol == '+')
        if (l.Nenner == 0 || r.Nenner == 0)
            throw MinusUnendlichUndPlusUnendlich();

    if (symbol == 0)
        if ((l.Zaehler == 0 && r.Nenner == 0) || (l.Nenner == 0 && r.Zaehler == 0))
            throw NullMalUnendlich();

    if (symbol == '/') {
        if (l.Zaehler == 0 && r.Zaehler == 0)
            throw NullDurchNull();
        if (l.Zaehler != 0 && l.Nenner == 0 && r.Zaehler != 0 && r.Nenner == 0)
            throw UnendlichDurchUnendlich();
    }

    if (symbol == '*') {
        if ((l.Zaehler == 0 || l.Nenner == 0)&&(r.Zaehler == 0 || r.Nenner == 0))
            throw KeineZahl();
    }
}


PM MAIL   Вверх
Killer_13
Дата 26.10.2010, 13:20 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 740
Регистрация: 12.1.2008
Где: Germany

Репутация: 1
Всего: 1



Дык понимаете в мейн, код должен остаться, нам нужно только проверку вставлять в функции "тест".
Что же делать?  :(
PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "C/C++: Для новичков"
JackYF
bsa

Запрещается!

1. Публиковать ссылки на вскрытые компоненты

2. Обсуждать взлом компонентов и делиться вскрытыми компонентами

  • Действия модераторов можно обсудить здесь
  • С просьбами о написании курсовой, реферата и т.п. обращаться сюда
  • Вопросы по реализации алгоритмов рассматриваются здесь


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, JackYF, bsa.

 
1 Пользователей читают эту тему (1 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | C/C++: Для новичков | Следующая тема »


 




[ Время генерации скрипта: 0.0918 ]   [ Использовано запросов: 21 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.