Алгоритмизация. Массивы С++
Троки матрицы циклически сдвинуть вниз на 2 позиции
Троки матрицы циклически сдвинуть вниз на 2 позиции
#include "iostream"
#include "iomanip"
#include "ctime"
#include "cstdlib"
#include "valarray"
using namespace std;
int main(){
int n,m; srand(time(NULL));
cout<<"Enter the sizes of array: "; cin>>n>>m; cout<
for(int* &i:a)for(int j=0;j< m;j++)i[j]=rand()%199-99;
for(int* &i:a){for(int j=0;j< m;j++)cout<
#include
#include
#include
#include
using namespace std;
int main()
{
srand(time(NULL));
int n = rand() % 5 + 5, m = rand() % 5 + 5, a[n][m];
for(int i = 0; i < n || !(cout << endl); cout << endl, ++i)
for(int j = 0; j < m; cout << setw(3) << (a[i][j++] = rand() % 19 - 9));
for(int k = 0; k++ < 2; )
for(int i = n; --i; )
for(int j = 0, t, x; j < m; x = i == n - 1? 0 : i + 1, t = a[i][j], a[i][j] = a[x][j], a[x][j++] = t);
for(int i = 0; i < n; cout << endl, ++i)
for(int j = 0; j < m; cout << setw(3) << a[i][j++]);
}
Можно сделать вариант без дополнительного цикла (k), но лениво.