Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://otvet.mail.ru/question/228893262
- #include <stdio.h>
- int main()
- {
- int i,j,n, m,k=1 ;
- n = 5; m = 4;
- int arr[m][n];
- for(i=0;i<m;i++)//fill an array
- {
- for(j=0;j<n;j++)
- {
- arr[i][j] = k++;
- }
- }
- printf("%d\n",arr[3][2]);
- printf("ARRAY BEFORE SORTING:\n");
- for(i=0;i<m;i++)//print an array
- {
- for(j=0;j<n;j++)
- {
- printf("%d\t",arr[i][j]);
- }
- printf("\n");
- }
- for(i=0;i<m;i++)//move elements forward
- {
- for(j=0;j<n;j++)
- {
- if((i!=m)&&(j!=n))//all rows exepts last, all columns exept last
- {
- arr[i][j]= arr[i][j+1];
- }
- else //fill last element in each row
- {
- arr[i][j] = arr[i+1][0];
- }
- }
- }
- printf("ARRAY AFTER SORTING:\n");
- for(i=0;i<m;i++)//print an array
- {
- for(j=0;j<n;j++)
- {
- printf("%d\t",arr[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement