include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
const unsigned M=5;
void init_array(int A[][M], unsigned n);
void print_of_array(int A[][M], unsigned n);
void swap (int *pa, int *pb);
void changing_of_array(int A[][M], unsigned n);
int main(){
const unsigned N=5;
int A[N][M];
init_array(A,N);
print_of_array(A,N);
printf("\n");
changing_of_array(A,N);
getchar();
return 0;
}
void init_array(int A[][M], unsigned n){
for (unsigned i=0; i<n; i++)
for (unsigned j=0; j<M;j++)
A[i][j]=rand()%100;
void print_of_array(int A[][M], unsigned n){
for (unsigned i=0; i<n; i++){
printf("%5d", A[i][j]);
printf("\n");}
void swap(int *pa, int *pb){
int temp=*pa;
*pa=*pb;
*pb=temp;
return;
void changing_of_array(int A[][M], unsigned n) {
unsigned l=1;
for (unsigned i=1; i<n; i++) {
for (unsigned j=M-1; j+1>0; j--){
if ((j-l)<0) break;
swap(&A[i][j],&A[i][j-l]); }
l++;
Объяснение:
include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
const unsigned M=5;
void init_array(int A[][M], unsigned n);
void print_of_array(int A[][M], unsigned n);
void swap (int *pa, int *pb);
void changing_of_array(int A[][M], unsigned n);
int main(){
const unsigned N=5;
int A[N][M];
init_array(A,N);
print_of_array(A,N);
printf("\n");
printf("\n");
changing_of_array(A,N);
print_of_array(A,N);
getchar();
return 0;
}
void init_array(int A[][M], unsigned n){
for (unsigned i=0; i<n; i++)
for (unsigned j=0; j<M;j++)
A[i][j]=rand()%100;
}
void print_of_array(int A[][M], unsigned n){
for (unsigned i=0; i<n; i++){
for (unsigned j=0; j<M;j++)
printf("%5d", A[i][j]);
printf("\n");}
}
void swap(int *pa, int *pb){
int temp=*pa;
*pa=*pb;
*pb=temp;
return;
}
void changing_of_array(int A[][M], unsigned n) {
unsigned l=1;
for (unsigned i=1; i<n; i++) {
for (unsigned j=M-1; j+1>0; j--){
if ((j-l)<0) break;
swap(&A[i][j],&A[i][j-l]); }
l++;
}
}
Объяснение: