srand(time(0));
int choice;
int count;
const int length = 8;
const int width = 5;
int A[width][length]{};
for (size_t i = 0; i < width; i++) {
}
cout << endl << endl;
do {
} while (choice != 1 && choice != 2);
cout << "Enter count:" << endl;
cin >> count;
switch (choice) {
case 1:
case 2:
}
cout << endl << endl;
cout << "Result:" << endl;
for (size_t i = 0; i < width; i++) {
}
system("pause");
int choice;
int count;
const int length = 8;
const int width = 5;
int A[width][length]{};
for (size_t i = 0; i < width; i++) {
for (size_t j = 0; j < length; j++) {
A[i][j] = rand() % 100;}
cout.width(3);
cout << A[i][j];
cout << endl;
}
cout << endl << endl;
do {
cout << "Enter a shift direction of the array:" << endl
<< "1 - Left" << endl << "2 - Right" << endl;cin >> choice;
} while (choice != 1 && choice != 2);
cout << "Enter count:" << endl;
cin >> count;
switch (choice) {
case 1:
for (int k = 0; k < count; k++) {
for (size_t i = 0; i < width; i++) {}
int tmp = A[i][0];}
for (size_t j = 0; j < length-1; j++)
A[i][j] = A[i][j + 1];A[i][length-1] = tmp;
break;
case 2:
for (int k = 0; k < count; k++) {
for (size_t i = 0; i < width; i++) {}
int tmp = A[i][length - 1];}
for (size_t j = length - 1; j > 0; j--)
A[i][j] = A[i][j - 1];A[i][0] = tmp;
break;
}
cout << endl << endl;
cout << "Result:" << endl;
for (size_t i = 0; i < width; i++) {
for (size_t j = 0; j < length; j++) {
cout.width(3);}
cout << A[i][j];
cout << endl;
}
system("pause");
Комментариев нет:
Отправить комментарий