Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <clocale>
- using namespace std;
- void printMatrix (double Matrix[][5]) {
- cout << "MATRIX" << '\n';
- for (int i = 0; i < 5; i++) {
- cout << '(';
- for (int j = 0; j < 5; j++) {
- cout << ' ' << Matrix[i][j] << ' ';
- }
- cout << ')' << '\n';
- }
- }
- int main() {
- setlocale(LC_ALL, "Rus");
- double a[5][5];
- int i, j, s = 0, x;
- cout << "Введите искомое число х: ";
- cin >> x;
- cout << "Введите элементы для матрицы A(" << 5 << " x " << 5 << "):" << endl;
- for (i = 0; i < 5; i++) {
- for (j = 0; j < 5; j++) {
- cin >> a[i][j];
- if (i % 2 == 0 and a[i][j] == x) s++;
- }
- }
- printMatrix(a);
- cout << "Кол-во элементов равных числу " << x << " в каждой из нечетных строк матрицы: " << s;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment