Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void read_arr(int A[], int N) {
- for (int i = 0; i < N; i++) {
- cin >> A[i];
- }
- }
- int get_sum(int A[], int N) {
- int sum = 0;
- for (int i = 0; i < N; i++) {
- sum += A[i];
- }
- return sum;
- }
- int get_product(int A[], int N) {
- int product = 1;
- for (int i = 0; i < N; i++) {
- product *= A[i];
- }
- return product;
- }
- int get_max(int A[], int N) {
- int max = A[0];
- for (int i = 0; i < N; i++) {
- if (A[i] > max) {
- max = A[i];
- }
- }
- return max;
- }
- int get_min(int A[], int N) {
- int min = A[0];
- for (int i = 0; i < N; i++) {
- if (A[i] < min) {
- min = A[i];
- }
- }
- return min;
- }
- void write_arr(int A[], int N) {
- for (int i = 0; i < N-1; i++) {
- cout << A[i] << ", ";
- }
- cout << A[N - 1];
- }
- int main()
- {
- int N;
- cin >> N;
- int A[1000];
- read_arr(A, N);
- cout << "sumata " << get_sum(A, N) << endl;
- cout << "proizvedenie " << get_product(A, N) << endl;
- cout << "max " << get_max(A, N) << endl;
- cout << "min " << get_min(A, N) << endl;
- cout << "recicata " << endl;
- write_arr(A, N);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement