fork download
  1. #include <stdio.h>
  2.  
  3.  
  4.  
  5. int main() {
  6. int a = 5, b = 10;
  7. printf("Avant: a = %d, b = %d\n", a, b);
  8.  
  9. // Méthode avec variable temporaire (plus simple)
  10. int temp = a;
  11. a = b;
  12. b = temp;
  13.  
  14. // Méthode sans variable (arithmétique)
  15. // a = a + b;
  16. // b = a - b;
  17. // a = a - b;
  18.  
  19. printf("Après: a = %d, b = %d\n", a, b);
  20. return 0;
  21. }
  22.  
  23.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Avant: a = 5, b = 10
Après: a = 10, b = 5