Add student example inputs

This commit is contained in:
Alex Hirsch
2019-03-18 13:50:36 +01:00
parent 480716b4a9
commit 14da3497ed
45 changed files with 1245 additions and 0 deletions

45
examples/euclid/euclid.mc Normal file
View File

@@ -0,0 +1,45 @@
int euclid(int n, int k)
{
if (k == 0) {
return n;
}
if (n == 0) {
return k;
}
if (n > k) {
return euclid(n - k, k);
} else {
return euclid(n, k - n);
}
}
int main()
{
print("Please enter the first number: ");
print_nl();
int n;
n = read_int();
print("Please enter the second number: ");
print_nl();
int k;
k = read_int();
print_nl();
int result;
result = euclid(n, k);
print("euclid(");
print_int(n);
print(", ");
print_int(k);
print(") = ");
print_int(result);
print_nl();
return 0;
}

View File

@@ -0,0 +1,2 @@
1071
1029

View File

@@ -0,0 +1,4 @@
Please enter the first number:
Please enter the second number:
euclid(1071, 1029) = 21