# Commits

committed eab4f6f

Exercises for week 1 (11/03/2011)

- Eykleid algorithm
- Same with recursion

• Participants

# .hgeol

`+[patterns]`
`+** = native`
`+`
`+[repository]`
`+native = CRLF`

`+#include <stdio.h>`
`+#include <stdlib.h>`
`+#define DEBUG 0`
`+`
`+main()`
`+{`
`+    int x, y, z, count, fx, fy;`
`+    `
`+    do`
`+    {`
`+        printf("Eisagete akeraio X :\n");`
`+        scanf("%d", &x);`
`+    } while(x<=0);`
`+    printf("\n");`
`+    `
`+    do`
`+    {`
`+        printf("Eisagete akeraio Y :\n");`
`+        scanf("%d", &y);`
`+    } while(y<=0);`
`+    printf("\n");`
`+    `
`+    fx = x;`
`+    fy = y;`
`+    count = 0;`
`+    z = y;`
`+    `
`+    while(z!=0)`
`+    {`
`+        z = x%y;`
`+        x = y;`
`+        y = z;`
`+        count++;`
`+        if(DEBUG)`
`+            printf("%3d %10d %10d %10d\n", count, x, y, z);`
`+    }`
`+    `
`+    printf("\nO MKD twn %d, %d einai o %d\n", fx, fy, x);`
`+    printf("Brethike meta apo %d bhmata\n\n", count);`
`+`
`+    system("pause");`
`+}`

`+#include <stdio.h>`
`+#include <stdlib.h>`
`+#define DEBUG 0`
`+`
`+int mkd(int x, int y);`
`+`
`+int count=0;`
`+`
`+main()`
`+{`
`+    int x, y;`
`+    `
`+    do`
`+    {`
`+        printf("Eisagete akeraio X :\n");`
`+        scanf("%d", &x);`
`+    } while(x<=0);`
`+    printf("\n");`
`+    `
`+    do`
`+    {`
`+        printf("Eisagete akeraio Y :\n");`
`+        scanf("%d", &y);`
`+    } while(y<=0);`
`+    printf("\n");`
`+`
`+`
`+    printf("\nO MKD twn %d, %d einai o %d\n", x, y, mkd(x,y));`
`+    printf("Brethike meta apo %d bhmata\n\n", count);`
`+`
`+`
`+    system("pause");`
`+}`
`+`
`+`
`+int mkd(int x, int y)`
`+{`
`+    count++;`
`+    if(DEBUG)`
`+        printf("%3d %10d %10d %10d\n", count, x, y, (y!=0)?x%y:0);`
`+`
`+    if(y==0)`
`+        return x;`
`+    else`
`+    {`
`+        return mkd(y, x%y);`
`+    }`
`+}`