Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <ctime>
  6. using namespace std;
  7.  
  8. void Ziehung(int* arrZahlen)
  9. {
  10. for(int i=0; i<6; ++i)
  11. arrZahlen[i] = rand()%(49-i);
  12. }
  13.  
  14. int main()
  15. {
  16. srand(time(NULL));
  17. int Zufallszahlen[6];
  18. Ziehung(Zufallszahlen);
  19.  
  20. vector<int> Lottokugeln;
  21.  
  22. for (int i=0; i<49; i++){
  23.     Lottokugeln.push_back(i);
  24.     }
  25.    
  26.     int zahlenTipp[6];
  27.     int anzahlRichtige = 0;
  28.    
  29. for (int i=0; i<6; i++){
  30.     cout << i << ". Tipp: " ;
  31.     int z=0;
  32.     cin >> z;
  33.     zahlenTipp[i]=z;
  34. }
  35.  
  36. vector<int> LottokugelnZiehung;
  37.    
  38. for (int i=0; i<6; i++){
  39.     int c = Zufallszahlen[i];
  40.     LottokugelnZiehung.push_back(Lottokugeln.at(c));
  41.     Lottokugeln.erase(Lottokugeln.begin()+c);
  42.    
  43.     }
  44.  
  45. vector<int>::iterator it;
  46.    
  47. for (int i=0; i<6; i++){
  48.     it = find(LottokugelnZiehung.begin(), LottokugelnZiehung.end(), zahlenTipp[i]);
  49.     if (it!=LottokugelnZiehung.end()){
  50.         anzahlRichtige++;
  51.     }
  52. }
  53.  
  54. cout << "Gezogene Lottozahlen: " << LottokugelnZiehung.at(0);
  55. for(int i=1; i<6; ++i)
  56. cout << ", " << LottokugelnZiehung.at(i);
  57. cout << endl;
  58.  
  59. cout << "Dein Tipp: " << zahlenTipp[0];
  60. for(int i=1; i<6; ++i)
  61. cout << ", " << zahlenTipp[i];
  62. cout << endl;
  63. cout << "Du hast " << anzahlRichtige << " Richtige!" << endl;
  64.  
  65. return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement