I am working on this problem:
Given an array p[5], write a function to shift it circularly left by two positions. Thus, if p[0] = 15, p[1]= 30, p[2] = 28, p[3]= 19 and p[4] = 61 then after the shift p[0] = 28, p[1] = 19, p[2] = 61, p[3] = 15 and p[4] = 30. Call this function for a (4 x 5 ) matrix and get its rows left shifted.
Here's the code I tried:
#include <stdio.h>
#include <stdio.h>
void circularswap(int arr[][5],int n,int m){ int arr1[n][m],i,j;
for (i=0;i<n;i++){
for (j=0;j<m;j++){
arr1[i][j]=*(*(arr+i)+j);
}
}
for (i=0;i<m;i++){
*(*(arr+i)+0)=arr1[i][2];
*(*(arr+i)+1)=arr1[i][3];
*(*(arr+i)+2)=arr1[i][4];
*(*(arr+i)+3)=arr1[i][0];
*(*(arr+i)+4)=arr1[i][1];
}
for (i=0;i<4;i++){
for (j=0;j<5;j++){
printf ("%d",arr[i][j]);
}
printf ("
");
}
}
int main(){ int i,j;
int arr[4][5]={(15,30,28,19,61),(15,30,28,19,61),(15,30,28,19,61),(15,30,28,19,61)};
circularswap((arr,4,5));
return 0;
}
Unfortunately, this shows up warnings. Can someone please tell why the warnings pop up and how to remove them?
question from:
https://stackoverflow.com/questions/65880514/why-does-the-program-display-warning-passing-argument-1-of-circularswap-makes 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…