Advertisement
kanciastopantalones

zagduje 1 z 20 losowych

Mar 16th, 2011
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <time.h>
  4. using namespace std;
  5. int tab[20];
  6. int main()
  7. {
  8. srand(time(0));
  9. for(int i=1;i<=20;i++)
  10. {
  11.         tab[i]=rand()%21;
  12.         cout << tab[i] << "  ";
  13.         }
  14. cout << endl << "odgadnij cyfre od 0 do 20: ";
  15. int a;
  16. int b=0;
  17. cin >> a;
  18. for (int j=1;j<=20;j++)
  19. {
  20. if (a==tab[j])
  21. {
  22.               b=b+1;
  23.               }
  24. }
  25.  
  26. if (b>=1) cout << "jest taka cyfra";
  27. if (b<1) cout << "nie ma takiej cyfry";
  28. getchar();
  29. cin.ignore();
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement