fork download
  1. #include <stdio.h>
  2.  
  3. struct Result{
  4. int output1[100];
  5. };
  6.  
  7. void cal(int n, int k, int a[])
  8. {
  9. struct Result result = {.output1 = {0} };
  10. int i,temp;
  11. k=k%n+1;
  12. result.output1[0] = a[k-1];
  13. for(i=1;i<k;i++)
  14. result.output1[i] = a[i-1];
  15. for(i=k;i<n;i++)
  16. result.output1[i] = a[i];
  17. // return result;
  18. for(i=0;i<n;i++)
  19. printf("%d\n",result.output1[i]);
  20.  
  21. }
  22.  
  23. int main() {
  24. // your code goes here
  25. int a[4]={1,2,3,4};
  26. cal(4,5,a);
  27. }
Success #stdin #stdout 0s 5296KB
stdin
Standard input is empty
stdout
2
1
3
4