Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void Ein_Ausgabe()
- {
- int ein;
- cout << "Bitte zahl eingeben: ";
- cin >> ein;
- cout << "Das doppelte der Zahl lautet: " << ein*2 << endl << endl;
- }
- void Aus1( double a )
- {
- cout << "\nDer Wert der Funktion lautet: " << a << endl << endl;
- }
- char gk( char a )
- {
- char r;
- if(a>='A' && a<='Z'){r='+';}
- else if(a>='a' && a<='z'){r='-';}
- else{r='?';}
- return r;
- }
- void swap( int &a, int &b )
- {
- int c = a;
- a = b;
- b = c;
- }
- double test_default( double a, double b = 0)
- {
- if(b==0){return a*a;}
- else return a*b;
- }
- void setze_variable(string &s)
- {
- s = "Teste Call-by-reference";
- }
- int main()
- {
- int n;
- cout << "Welche Aufagabe? ( 1 - 7)";
- while(n<1||n>7)
- {
- cin >> n;
- }
- if(n==1)
- {
- cout << endl << "Aufgabe 1!\n\n";
- Ein_Ausgabe();
- }
- else if(n==2)
- {
- cout << endl << "Aufgabe 2!\n\n";
- const double e = 12.6;
- Aus1(e);
- }
- else if(n==3)
- {
- cout << endl << "Aufgabe 3!\n\n";
- double f;
- cout << endl << "Bitte Zahl eingeben: ";
- cin >> f;
- Aus1(f);
- }
- else if(n==4)
- {
- cout << endl << "Aufgabe 4!\n\n";
- char g,h;
- cout << endl << "Bitte Buchstaben eingeben: ";
- cin >> g;
- h = gk(g);
- cout << endl << h << endl;
- }
- else if(n==5)
- {
- cout << endl << "Aufgabe 5!\n\n";
- string s = "text";
- cout << endl << "Text vorher: " << s << endl;
- setze_variable(s);
- cout << endl << "Text nachher: " << s << endl;
- }
- else if(n==6)
- {
- cout << endl << "Aufgabe 6!\n\n";
- cout << endl << "Bitte 1 oder 2 Zahlen eingeben: (Bei 0 wird die vorherige Zahl quadriert ";
- double i,j,k;
- cin >> i;
- cin >> j;
- k = test_default(i,j);
- cout << endl << "Lösung: " << k << endl;
- }
- else if(n==7)
- {
- cout << endl << "Aufgabe 7!\n\n";
- cout << endl << "Bitte 2 Zahlen eingeben: ";
- int l,m;
- cin >> l;
- cin >> m;
- cout << endl << "Zahlen vorher: a: " << l << " b: " << m << endl;
- swap(l,m);
- cout << endl << "Zahlen nachher: a: " << l << " b: " << m << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement