[ create a new paste ] login | about

Link: http://codepad.org/ETf2XcdR    [ raw code | output | fork ]

appunti2 - C, pasted on May 1:
#include <stdio.h>

char *input_1 = "111";  // al posto di argv[1];
char *input_2 = "1234"; // al posto di argv[2];

#include <stdio.h>

int
mcd (int x, int y)
{
    while (x != y)
      {
        if (x > y)
          {
            x = x - y;
          }
        else
          {
            y = y - x;
          }
      }

    return x;
}

int
main (int argc, char *argv[])
{
    int x;
    int y;
    int z;

    sscanf (input_1, "%i", &x);
    sscanf (input_2, "%i", &y);

    z = mcd (x, y);

    printf ("Il massimo comune divisore di %i e %i è %i\n",
            x, y, z);

    return 0;
}


Output:
1
Il massimo comune divisore di 111 e 1234 è 1


Create a new paste based on this one


Comments: