0

what is the error in this code can anyone help me!

what is the error in this code can anyone help me! #include<stdio.h> int main() { int size,rot,testcase,array[15],demo[15],i,j,k,s,r; scanf("%d %d %d",&testcase,&size,&rot); while(testcase>0) { s=size; for(i=0;i<size;i++) { scanf("%d",&array[i]); } for(r=0;rot>0;r++) { for(j=0;j<size;j++) { demo[j]=array[j]; } for(k=0;k<size;k++) { array[k]=demo[s-1]; s--; } rot--; } testcase--; } for(i=0;i<size;i++) { printf("%d \n",array[i]); } } c Here T is 1, which means one test case. denoting the number of elements in the array and , denoting the number of steps of rotations. The initial array is: 1,2,3,4,5 In first rotation, 5 will come in the first position and all other elements will move to one position ahead from their current position. Now, the resultant array will be 5,1,2,3,4.In second rotation, 4 will come in the first position and all other elements will move to one position ahead from their current position. Now, the resultant array will be 4,5,1,2,3.

27th Aug 2021, 9:02 AM
Jenishan Vijayakumar
Jenishan Vijayakumar - avatar
3 Respuestas
+ 2
I made a program that might help you https://code.sololearn.com/ce9Uikh1uLMT
28th Aug 2021, 2:16 PM
SoloProg
SoloProg - avatar
0
thank you
29th Aug 2021, 6:42 AM
Jenishan Vijayakumar
Jenishan Vijayakumar - avatar
0
#include<stdio.h> int main() { int size,rot,testcase,array[10],d,i,j,k,s,r; scanf("%d %d %d",&testcase,&size,&rot); while(testcase>0) { s=size-1; for(i=0;i<size;i++) { scanf("%d",array[i]); } for(r=0;rot>r;r++) { j=array[s]; for(k=1;k<size;k++) { array[s]=array[s-1]; s--; } array[0]=j; } testcase--; } for(d=0;d<size;d++) { printf("%d \n",array[d]); } return 0; } //i make this but it is not work properly.
29th Aug 2021, 6:44 AM
Jenishan Vijayakumar
Jenishan Vijayakumar - avatar