Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4. void read_arr(int A[], int N) {
  5.     for (int i = 0; i < N; i++) {
  6.         cin >> A[i];
  7.     }
  8. }
  9. int get_sum(int A[], int N) {
  10.     int sum = 0;
  11.     for (int i = 0; i < N; i++) {
  12.         sum += A[i];
  13.     }
  14.     return sum;
  15. }
  16. int get_product(int A[], int N) {
  17.     int product = 1;
  18.     for (int i = 0; i < N; i++) {
  19.         product *= A[i];
  20.     }
  21.     return product;
  22. }
  23. int get_max(int A[], int N) {
  24.     int max = A[0];
  25.     for (int i = 0; i < N; i++) {
  26.         if (A[i] > max) {
  27.             max = A[i];
  28.         }
  29.     }
  30.     return max;
  31. }
  32. int get_min(int A[], int N) {
  33.     int min = A[0];
  34.     for (int i = 0; i < N; i++) {
  35.         if (A[i] < min) {
  36.             min = A[i];
  37.         }
  38.     }
  39.     return min;
  40. }
  41. void write_arr(int A[], int N) {
  42.     for (int i = 0; i < N-1; i++) {
  43.         cout << A[i] << ", ";
  44.     }
  45.     cout << A[N - 1];
  46. }
  47. int main()
  48. {
  49.     int N;
  50.     cin >> N;
  51.     int A[1000];
  52.     read_arr(A, N);
  53.     cout << "sumata " << get_sum(A, N) << endl;
  54.     cout << "proizvedenie " << get_product(A, N) << endl;
  55.     cout << "max " << get_max(A, N) << endl;
  56.     cout << "min " << get_min(A, N) << endl;
  57.     cout << "recicata " << endl;
  58.     write_arr(A, N);
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement