Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- const int N = 3;
- const int P = 4;
- int summ(int number)
- {
- int F = number;
- int sum = 0;
- while (F > 0)
- {
- sum += F % 10;
- F = F / 10;
- }
- return sum;
- }
- void cinn(int a[N][P], int N, int P)
- {
- cout << "Введите элементы массива" << endl;
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < P; j++)
- {
- cin >> a[i][j];
- }
- cout << endl;
- }
- }
- void coutt(int a[N][P], int N, int P)
- {
- cout << "Вывод элементов " << endl;
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < P; j++)
- {
- cout << a[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- }
- void summ_numbers(int* a, int N )
- {
- cout << "Сумма цифр для каждого элемента стобца" << endl;
- for (int j = 0; j < N; j++)
- {
- cout << summ(a[j]) << " " << endl;
- }
- }
- int main()
- {
- int a[N][P];
- int k[P];
- setlocale(LC_ALL, "Rus");
- srand(time(NULL));
- cout <<" Сортировать стобцы по сумм цифр " <<endl;
- cinn(a, N, P);
- coutt(a, N, P);
- summ_numbers(*a, N);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement