zuerst einmal muss afaik statt:
abbruch = j
abbruch == j stehen.
nur 1 gleichheitszeichen bedeutet deklinieren
dann in der if schleife unbedingt abbruch wieder gleich 0 setzen!
allerdings geht er dann bei ja auch immer wieder aus ^^
ich wette das is alles viel zu kompliziert ~_~ die coder hier lachen uns bestimmt aus xD
? dann stell ich meinen tollen code auch ma rein >.< hab nen taschenrechner gemacht. ich brauch auch die lösung wie man wieder an den Anfang des Programms kommt. (mit j/n)
JA, ich weiß, ein taschenrechner für binom. formeln is sinnlos ~~ aber ich wollte soviel wie möglich reintun zum üben
Quote:
#include <iostream>
using namespace std;
float zahl1;
float zahl2;
float ergebnis;
int auswahl;
int abbruch;
char j;
char n;
main()
{
* * * Start:
* * * cout << "~~~~~~~~~~~Taschenrechner~~~~~~~~~~~~" << endl;
* * * cout << "Wollen sie \"plus\"(1) oder \"minus\"(2) oder" \
* * * "\"mal\"(3) oder \"geteilt\"(4) oder \"hoch\"(5) oder \"binom. formel\"(6) rechnen?" << endl;
* * * cin >> auswahl;
* * * if (auswahl == 1)
* * * {
* * * cout << "sie wollen also plus rechnen. geben sie die erste zahl ein" << endl;* * *
* * * cin >> zahl1;
* * * cout << "jetzt die zweite" << endl;
* * * cin >> zahl2;
* * * ergebnis = zahl1 + zahl2;
* * * cout << zahl1 << " + " << zahl2 << " = " << ergebnis << endl;
* * * * * * cout << " nochmal rechnen? " << endl;
* * * * * * cin >> abbruch;
* * * * * * * * if (abbruch == j)
* * * * * * * * {
* * * * * * * * * * * * * * abbruch = 1;
* * * * * * * * * * * * * * goto Start;
* * * * * * * * * * * * * *
* * * * * * * * * * * * * * }
* * * * * * * * else if (abbruch == n)
* * * * * * * * {
* * * * * * * * * * abbruch = 1;
* * * * * * * * * * return 0;
* * * * * * * * * *
* * * * * * * * * * }
* * * * * * * * else
* * * * * * * * {
* * * * * * * * * * cout << "~.~" << endl;
* * * * * * * * * * };
* *
* * * }
* * * else if (auswahl == 2)
* * * {
* * * cout << "sie wollen also minus rechnen. geben sie die erste zahl ein" << endl;* * *
* * * cin >> zahl1;
* * * cout << "jetzt die zweite" << endl;
* * * cin >> zahl2;
* * * ergebnis = zahl1 - zahl2;
* * * cout << zahl1 << " - " << zahl2 << " = " << ergebnis << endl;
* * * }
* * * else if (auswahl == 3)
* * * {
* * * cout << "sie wollen also mal rechnen. geben sie die erste zahl ein" << endl;* * *
* * * cin >> zahl1;
* * * cout << "jetzt die zweite" << endl;
* * * cin >> zahl2;
* * * ergebnis = zahl1 * zahl2;
* * * cout << zahl1 << " * " << zahl2 << " = " << ergebnis << endl;
* * * }
* * * else if (auswahl == 4)
* * * {
* * * cout << "sie wollen also geteilt rechnen. geben sie die erste zahl ein" << endl;* * *
* * * cin >> zahl1;
* * * cout << "jetzt die zweite" << endl;
* * * cin >> zahl2;
* * * ergebnis = zahl1 / zahl2;
* * * cout << zahl1 << " / " << zahl2 << " = " << ergebnis << endl;
* * * }
* * * else if (auswahl == 5)
* * * {cout << "sie wollen also hoch rechnen. geben sie die erste zahl ein" << endl;* * *
* * * cin >> zahl1;
* * * cout << "jetzt die, mit der sie die zahl 1 hochnehmen wollen" << endl;
* * * cin >> zahl2;
* * * ergebnis = zahl1;
* * * for (float schleife1 = 1; schleife1 != zahl2; schleife1++ )
* * * {
* * * * * * ergebnis = ergebnis * zahl1;
* * * * * *
* * * }
* * * cout << zahl1 << " ^ " << zahl2 << " = " << ergebnis << endl;
* * * }
* * * else if (auswahl == 6)
* * * {
* * * int auswahl_binom;
* * * float a;
* * * float b;
* * * cout << "welche binom. formel wollen sie rechen? 1, 2, 3?" << endl;
* * * cin >> auswahl_binom;
* * * * * if (auswahl_binom == 1)
* * * * * {
* * * * * cout << "a?" << endl;
* * * * * cin >> a;
* * * * * cout << "b?" << endl;
* * * * * cin >> b;
* * * * * ergebnis = (a*a) + 2*(a*b) + (b*b);
* * * * * cout << "binom. formel 1, mit a " << a << " b " << b << " = " << ergebnis<< endl;
* * * * * }
* * * * * else if (auswahl_binom == 2)
* * * * * {
* * * * * cout << "a?" << endl;
* * * * * cin >> a;
* * * * * cout << "b?" << endl;
* * * * * cin >> b;
* * * * * ergebnis = (a*a) - 2*(a*b) + (b*b);
* * * * * cout << "binom. formel 2, mit a " << a << " b " << b << " = " << ergebnis<< endl;
* * * * * }
* * * * * else if (auswahl_binom == 3)
* * * * * {{
* * * * * cout << "a?" << endl;
* * * * * cin >> a;
* * * * * cout << "b?" << endl;
* * * * * cin >> b;
* * * * * ergebnis = (a*a)-(b*b);
* * * * * cout << "binom. formel 3, mit a " << a << " b " << b << " = " << ergebnis<< endl;
* * * * * }
* * * }
* * * * *
}* *
};
|