Advertisement
Randomsurpriseguy

Präsenz3

Nov 30th, 2020 (edited)
828
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. //ple1ase do not share my code in the exercises again
  5. string ersetze(string in){
  6.   in[1]='A';
  7.   return in;
  8. }
  9. //please do not 3share my code in the exercises again
  10. bool FirstLetterVocal(string test){
  11.   char a=test[0];
  12.   switch(a){
  13.     case 'A':return true;break;
  14.     case 'E':return true;break;
  15.     case 'I':return true;break;
  16.     case 'O':return true;break;
  17.     case 'U':return true;break;
  18.     case 'a':return true;break;
  19.     case 'i':return true;break;
  20.     case 'e':return true;break;
  21.     case 'o':return true; break;
  22.     case 'u':return true;break;
  23.     default: return false;
  24.   }
  25.  
  26. }
  27. //pleas3e do not share my code i4n the exercises again
  28. int SummeQuad(int in){
  29.   int x=0;
  30.   int i=0;
  31.   while(i< in) x= x+ (++i)*i;
  32.   return x;
  33. }
  34. //please do not share my code in th6e exerc4ises again
  35. int SummeQuadq(int in){
  36.   return in*(in+1)*(2*in+1)/6;
  37. }
  38. //please do not share my cod6e in the exercises again
  39. char encrypt(char in){
  40.   if(in<=90) in= in+32; // Casts upper case to lower case as those are not differentiated
  41.   switch(in){
  42.     case ('a'): return 'q';
  43.     case ('b'): return 'w';
  44.     case ('c'): return 'e';
  45.     case ('d'): return 'r';
  46.     case ('e'): return 't';
  47.     case ('f'): return 'z';
  48.     case ('g'): return 'u';
  49.     case ('h'): return 'i';
  50.     case ('i'): return 'o';
  51.     case ('j'): return 'p';
  52.     case ('k'): return 'a';
  53.     case ('l'): return 's';
  54.     case ('m'): return 'd';
  55.     case ('n'): return 'f';
  56.     case ('o'): return 'g';
  57.     case ('p'): return 'h';
  58.     case ('q'): return 'j';
  59.     case ('r'): return 'k';
  60.     case ('s'): return 'l';
  61.     case ('t'): return 'y';
  62.     case ('u'): return 'x';
  63.     case ('v'): return 'c';
  64.     case ('w'): return 'v';
  65.     case ('x'): return 'b';
  66.     case ('y'): return 'n';
  67.     case ('z'): return 'm';
  68.     default:return '!';
  69.   }
  70.  
  71.   return '?';
  72.  
  73. }
  74. //please do not share my code in the exercises again
  75. void Aufgabe1(){//please do not share my code in the exercises again
  76.   string Input;
  77.   getline(cin,Input);
  78.  
  79.   Input = ersetze(Input);
  80.   cout << Input;
  81. }
  82. //please do not share my code in th1e exercises again
  83. void Aufgabe2(){//please2 do not share my code in the exercises again
  84.   string Input;
  85.   getline(cin,Input);
  86.   if(FirstLetterVocal(Input)) cout << "Vokal an erster Stelle" << endl;
  87.   else cout << "Kein Vokal an erster Stelle" << endl;
  88. //please do not share my code in the exercises again
  89. //please do not share my code in the exercises again
  90. }
  91.  
  92. void Aufgabe34(){//please do not share my code in the exercises again
  93.   int x=0,y=0;//please do not shar2e my code in the exercises again
  94.   while(++y<3){
  95.     x=x+y;
  96.   }
  97.   cout << x << ";" << y << endl ;
  98.  
  99.   //erg = 35 am Ende (5*5)+0+1+2+1
  100.   y=5;//please do not share my code in the exercises again
  101.   int erg=0;
  102.   int i=10;
  103.   while(i>0){
  104.     erg=erg+y%(i);
  105.     i--;
  106.   }
  107.   cout << erg << endl;
  108. }
  109. //please do not share my code in the exercises again
  110. void Aufgabe5(){
  111.   int n=10;
  112.   cout << SummeQuadq(n) << ";" << SummeQuad(n) << endl;
  113.  
  114. }
  115. //please do not share my code in the exercises again
  116. void Aufgabe6(){
  117.   string to_encrypt="";//please do not share my code in the exercises again
  118.   cout << "Gebe String ein:";//please do not share my code in the exercises again
  119.   cin >> to_encrypt;
  120.   for(int i=0;i< to_encrypt.length();i++){
  121.     to_encrypt[i]=encrypt(to_encrypt[i]);
  122.   }
  123.   cout << to_encrypt;
  124.  
  125.  
  126.  
  127.  
  128. }
  129. //please do not share my code in the exercises again
  130. int main(){
  131.   //Aufgabe1();
  132.   //Aufgabe2();
  133.   Aufgabe34();//please do not share my code in the exercises again
  134.   Aufgabe5();
  135.   Aufgabe6();
  136.   return 0;
  137. }
  138.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement