Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int max(int a, int b){
- return -min(-a,-b);
- }
- int min(int a, int b){
- if(a<b) return a;
- return b;
- }
- bool repr_letter(int in){
- return (in <= 122 && in >=97 || in <= 90 && in >= 65);
- }
- void sort(int* in){//simpler Sortieralgorithmus, ausreichend für ein Array mit Länge 3
- int i=0;
- int *intermed;
- bool change=true;
- while(change){
- change=false;
- i=0;
- while(i< 3-1){
- if(*(in+i) > *(in+i+1)){
- *intermed=*(in+i+1);
- *(in+i+1)=*(in+i);
- *(in+i)=*intermed;
- change=true;
- }
- i++;
- }
- }
- }
- int rechne(int x,int y, int z){
- int arr[3]={x,y,z};
- sort(arr);
- cout << (*arr * *(arr+2) + *(arr+1));
- return 0;
- }
- bool gerade(int in){
- return (in%2==0);
- }
- void Aufgabe1(){
- char in;
- cout << "Ueberpruefe auf Vokal/Konsonant:";
- cin >> in;
- if(repr_letter(in)){
- if(in == 'a' || in == 'e' || in == 'i' || in == 'o' || in == 'u' || in == 'A' || in == 'E' || in == 'I' || in == 'O' || in == 'U' ){
- cout << "Vokal" << endl;
- }else cout << "Konsonant" << endl;
- }
- else cout << "Kein Buchstabe" << endl;
- }
- void Aufgabe2(){
- char x,y,z;
- cout << "letter 1=";
- cin >> x;
- cout << "letter 2=";
- cin >> y;
- cout << "letter 3=";
- cin >> z;
- if(x < y){
- if(z < x){
- cout << z << "," << x << "," << y << endl; // z<x,x<y -> z<y
- }
- else{
- if(z<y){
- cout << x << "," << z << ","<< y << endl;
- }
- else cout << x << "," << y << "," << z << endl;
- }
- }else{
- if(z > x){
- cout << y << "," << x << ","<< z << endl; // z>x, x>y -> z>y
- }
- else{
- if(z>y){
- cout << y << "," << z << "," <<x << endl;
- }
- else cout << z << "," << y << "," << x << endl;
- }
- }
- }
- void Aufgabe3(){
- int testgerade;
- cout << "Gebe Integer zum Testen ein:";
- cin >> testgerade;
- if(gerade(testgerade)) cout << "Zahl ist gerade." << endl;
- else cout << "Zahl ist ungerade." << endl;
- }
- void Aufgabe4(){
- cout << min(-42,42) << endl;
- }
- void Aufgabe5(){
- rechne(1,3,-2);
- }
- int main(){
- /*Aufgabe1();
- Aufgabe2();*/
- Aufgabe3();
- Aufgabe4();
- Aufgabe5();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement