0

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]); } }

26th Aug 2021, 4:03 PM
Jenishan Vijayakumar
Jenishan Vijayakumar - avatar
1 Respuesta
0
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.
26th Aug 2021, 4:08 PM
Jenishan Vijayakumar
Jenishan Vijayakumar - avatar