Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void ex1() {
- int n[2][2] = { {0, 0}, {0, 0} }; // создание массива 2х2 и указание переменных
- int a, b, c, d, sum1, sum2;
- cout << "Введите элементы двумерного массива \n -> ";
- cin >> a >> b >> c >> d;
- for (int i = 0; i < 2; i++) { // заполнение массива
- for (int j = 0; j < 2; j++) {
- n[0][0] = a;
- n[0][1] = b;
- n[1][0] = c;
- n[1][1] = d;
- }
- }
- cout << " Ваш двумерный массив: \n"; // вывод массива
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < 2; j++) {
- cout << " " <<n[i][j] << " ";
- }
- cout << endl;
- }
- cout << " Сумма первой строки -> " << n[0][0] + n[0][1] << endl;
- cout << " Cумма второй строки -> " << n[1][0] + n[1][1] << endl;
- }
- void ex2() {
- int n[2][2] = { {0, 0}, {0, 0} };
- int a, b, c, d, sum1, sum2;
- cout << "Введите элементы двумерного массива \n -> ";
- cin >> a >> b >> c >> d;
- for (int i = 0; i < 2; i++) { // ввод массива
- for (int j = 0; j < 2; j++) {
- n[0][0] = a;
- n[0][1] = b;
- n[1][0] = c;
- n[1][1] = d;
- }
- }
- cout << " Ваш двумерный массив: \n"; // вывод массива
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < 2; j++) {
- cout << " " << n[i][j] << " ";
- }
- cout << endl;
- }
- cout << " Сумма первой строки -> " << n[0][0] + n[1][0] << endl;
- cout << " Cумма второй строки -> " << n[1][1] + n[0][1] << endl;
- }
- int main() {
- setlocale(0, "");
- // ex1();
- // ex2();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment