Mr Nobody
BANNED | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору #include <iostream> #include <stdlib.h> #include <time.h> const int ROW = 6; const int COL = 10; int mass[ROW][COL]; using namespace std; int main() { int row_1, row_2; int row, col, temp; srand((unsigned)time(NULL)); for(row = 0; row < ROW; row++) for(col = 0; col < COL; col++) mass[row][col] = rand() % 10000; // 4 digits numbers cout << "Enter number of first row less than " << ROW << " "; cin >> row_1; cout << "Enter number of second row less than " << ROW << " "; cin >> row_2; cout << "\n Matrix before change:\n\n"; for(row = 0; row < ROW; row++) { for(col = 0; col < COL; col++) { cout.width(4); cout << " " << mass[row][col]; } cout << "\n\n"; } row_1 %= ROW; row_2 %= ROW; for(col = 0; col < COL; col++) { temp = mass[row_1][col]; mass[row_1][col] = mass[row_2][col]; mass[row_2][col] = temp; } cout << "\n Matrix after change:\n\n"; for(row = 0; row < ROW; row++) { for(col = 0; col < COL; col++) { cout.width(4); cout << " " << mass[row][col]; } cout << "\n\n"; } return 0; } |