All pastes #93833 Raw Edit

Someone

public cpp v1 · immutable
#93833 ·published 2006-07-20 20:10 UTC
rendered paste body
// Lernen.cpp : Defines the entry point for the console application.//#include "stdafx.h"using namespace std;float Addiere(float Zahl1, float Zahl2) {	return Zahl1+Zahl2;}float Subtrahiere(float Zahl1, float Zahl2) {	return Zahl1-Zahl2;}float Multipliziere(float Zahl1, float Zahl2) {	return Zahl1*Zahl2;}float Dividiere(float Zahl1, float Zahl2) {	return Zahl1/Zahl2;}float Potenzrechnung (float Basis, float Exponent) {	float Ergebnis = Basis; // ergebnis mit dem wert von der float variable Zahl initialisieren..	for (int zaehler=1; zaehler<Exponent; zaehler++) {		Ergebnis = Ergebnis * Basis;	}	return Ergebnis;}int _tmain(int argc, _TCHAR* argv[]) {	string InputVar;	float ein_zahl1, ein_zahl2;	cout << "Bitte eingeben:\n  Addieren\n  Subtrahieren\n  Multiplizieren\n  Dividieren\n  Potenzieren\n\n  Exit\n\n";	NeuEingabe:   // Einsprungpunkt für GoTo nach Falscheingabe bzw. Fertigstellung nach				  // Rechnung	cout << "Befehl: ";	cin >> InputVar;	if ((InputVar == "Addieren") || (InputVar == "addieren")) {		cout << "Zahl 1: ";		cin >> ein_zahl1;		cout << "Zahl 2: ";		cin >> ein_zahl2;		cout << "\nErgebnis: " << Addiere(ein_zahl1,ein_zahl2) << "\n\n";		goto NeuEingabe;	}	else if ((InputVar == "Subtrahieren") || (InputVar == "subtrahieren")) {		cout << "Zahl 1: ";		cin >> ein_zahl1;		cout << "Zahl 2: ";		cin >> ein_zahl2;		cout << "Ergebnis: " << Subtrahiere(ein_zahl1,ein_zahl2) << "\n\n";		goto NeuEingabe;	}	else if ((InputVar == "Multiplizieren") || (InputVar == "multiplizieren")) {		cout << "Zahl 1: ";		cin >> ein_zahl1;		cout << "Zahl 2: ";		cin >> ein_zahl2;		cout << "Ergebnis: " << Multipliziere(ein_zahl1,ein_zahl2) << "\n\n";		goto NeuEingabe;	}	else if ((InputVar == "Dividieren") || (InputVar == "dividieren")) { 		cout << "Zahl 1: ";		cin >> ein_zahl1;		cout << "Zahl 2: ";		cin >> ein_zahl2;		cout << "Ergebnis: " << Dividiere(ein_zahl1,ein_zahl2) << "\n\n";		goto NeuEingabe;	}	else if ((InputVar == "Potenzieren") || (InputVar == "potenzieren")) { 		cout << "Basis: ";		cin >> ein_zahl1;		cout << "Exponent: ";		cin >> ein_zahl2;		cout << "Ergebnis: " << Potenzrechnung(ein_zahl1,ein_zahl2) << "\n\n";		goto NeuEingabe;	}	else if ((InputVar == "exit") || (InputVar == "Exit")) {		return 1;	}	else {		cout << "Error! Unbekannter Befehl!\n\n";		goto NeuEingabe;	}	while (1) { }	return 0;}