Advertisement
cwchen

array size

Mar 8th, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4.  
  5. using std::cout;
  6. using std::endl;
  7.  
  8. int main() {
  9.   int n;
  10.   cout << "Input n: ";
  11.   scanf("%d", &n);
  12.  
  13.   int result[n];
  14.  
  15.   srand(time(NULL));
  16.   for (int i = 0; i < n; i++) {
  17.     result[i] = rand() % 100 + 1;
  18.   }
  19.  
  20.   for (int i = 0; i < n; i++) {
  21.     cout << result[i] << " ";
  22.   }
  23.   cout << endl;
  24.  
  25.   return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement