Advertisement
DaniDori

Untitled

Mar 12th, 2023
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int N;
  8. cin >> N;
  9. int *arr = new int[N];
  10. double sum = 0;
  11. srand(time(NULL));
  12. for (int i = 0; i < N; i++) {
  13. cout << (arr[i] = rand() % 101) << ' ';
  14. if (i % 10 == 0)cout << endl;
  15. }
  16. for (int i = 0; i < N; i++) {
  17. sum += arr[i];
  18. }
  19. cout << endl << "answer: " << sum / N;
  20. }
  21.  
  22.  
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement