fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int tab[] = {1,2,3,4,5,6,7};
  5. int i;
  6. for (i = 0; i < 7; i+= 2) {
  7. int tmp = tab[i];
  8. tab[i] = tab[i+1];
  9. tab[i+1] = tmp;
  10. }
  11.  
  12. for (i = 0; i < 7; i++) {
  13. printf("%d ", tab[i]);
  14. }
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
2 1 4 3 6 5 1