Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int const n = 10;
- int const m = 10;
- int const k = 100;
- int a[m][n];
- int c = 0;
- //cout << "enter the number of strings & columns: ";
- //cin >> n;
- int b[k]{};
- for (int i = 0; i < m; i++) //заполнение и вывод
- {
- for (int j = 0; j < n; j++)
- {
- a[i][j] = rand() % 10;
- cout << a[i][j] << "\t";
- }
- cout << endl;
- }
- cout << endl;
- for (int i = 0; i < m; i++)
- {
- for (int j = 0; j < n; j++)
- {
- if (a[i][j]%3 == 0)
- {
- b[i]=a[i][j]; //запись элементов, кратных 3
- c++;
- }
- }
- }
- for (int i = 0; i <= c; i++) //вывод массива 2
- {
- cout << b[i] << "\t";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement