fork download
  1. #include <stdio.h>
  2.  
  3. int main(){
  4. int a[]={3,5,2,4,1,9,7,6,0,8},i,temp;
  5. printf("初期状態");
  6. for(i=0;i<10;i++){
  7. printf("%2d",a[i]);
  8. }
  9. temp=a[0];
  10. a[0]=a[3];
  11. a[3]=temp;
  12.  
  13. temp=a[3];
  14. a[3]=a[5];
  15. a[5]=temp;
  16.  
  17. temp=a[5];
  18. a[5]=a[8];
  19. a[8]=temp;
  20. printf("\n入れ替え後");
  21. for(i=0;i<10;i++){
  22. printf("%2d",a[i]);
  23. }
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
初期状態 3 5 2 4 1 9 7 6 0 8
入れ替え後 4 5 2 9 1 0 7 6 3 8