fork download
  1. #include <stdio.h>
  2.  
  3. char *input_1 = "111"; // al posto di argv[1];
  4. char *input_2 = "1234"; // al posto di argv[2];
  5.  
  6. #include <stdio.h>
  7.  
  8. int
  9. mcd (int x, int y)
  10. {
  11. while (x != y)
  12. {
  13. if (x > y)
  14. {
  15. x = x - y;
  16. }
  17. else
  18. {
  19. y = y - x;
  20. }
  21. }
  22.  
  23. return x;
  24. }
  25.  
  26. int
  27. main (int argc, char *argv[])
  28. {
  29. int x;
  30. int y;
  31. int z;
  32.  
  33. sscanf (input_1, "%i", &x);
  34. sscanf (input_2, "%i", &y);
  35.  
  36. z = mcd (x, y);
  37.  
  38. printf ("Il massimo comune divisore di %i e %i è %i\n",
  39. x, y, z);
  40.  
  41. return 0;
  42. }
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
Il massimo comune divisore di 111 e 1234 è 1