fork download
  1. #include<stdio.h>
  2. void reverse(int* a,int i,int j)
  3. {
  4. if(i==j) return;
  5. int index,temp=0;
  6. int mid=(j-i+1)/2;
  7. for(index=0;index<mid;index++,i++,j--)
  8. {
  9. temp=*(a+i);
  10. *(a+i)=*(a+j);
  11. *(a+j)=temp;
  12. }
  13. }
  14.  
  15. void rotate(int* arr,int N,int len)
  16. {
  17. if(N==len) return;
  18. reverse(arr,len-N,len-1);
  19. reverse(arr,0,len-N-1);
  20. reverse(arr,0,len-1);
  21. }
  22.  
  23. int main()
  24. {
  25. int arr[]={1,2,3,4,5};
  26. rotate(arr,7,5);
  27. for(i=0;i<5;i++)
  28. printf("%d\n",arr[i]);
  29. return 0;
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:27: error: ‘i’ undeclared (first use in this function)
prog.c:27: error: (Each undeclared identifier is reported only once
prog.c:27: error: for each function it appears in.)
stdout
Standard output is empty