Puntoinfinito

Random nums - With maximum

Oct 15th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include <string>
  4.  
  5. #include <cstdlib>
  6.  
  7. #include <ctime>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12.  
  13. {
  14.  
  15. int i = 0;
  16.  
  17. char a[10];
  18.  
  19. cin >> i;
  20.  
  21. srand(time(NULL));
  22.  
  23. for (int x = 0;x < 10;x++)
  24.  
  25. {
  26.  
  27. a[x] = rand() % i;
  28.  
  29. }
  30.  
  31. cout << a[0] + a[1] + a[2] + a[3] + a[4] + a[5] +a[6] + a[7] + a[8] + a[9] + a[10];
  32.  
  33. return 0;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment