Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <stdio.h>
- #include <locale.h>
- int Count(int A[], int a, int n)
- {
- int kol = 0;
- for (int i = 0; i < n; i++)
- if ((A[i] % a) == 0)
- kol++;
- return kol;
- }
- int Summa(int A[], int n)
- {
- int sum = 0;
- for (int i = 0; i < n; i++)
- if (A[i]> 0)
- sum += A[i];
- return sum;
- }
- int main()
- {
- setlocale(LC_ALL, "rus");
- int n, a;
- printf("Введите размер массива: ");
- scanf_s("%d", &n);
- int *A = new int[n];
- printf("Введите массив:\n");
- for (int i = 0; i < n; i++)
- scanf_s("%d", &A[i]);
- printf("Введите делитель: ");
- scanf_s("%d", &a);
- printf("Кол-во делителей: %d\n", Count(A, a, n));
- printf("Сумма положительных эле-тов: %d", Summa(A, n));
- delete A;
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement