Add student example inputs
This commit is contained in:
45
examples/euclid/euclid.mc
Normal file
45
examples/euclid/euclid.mc
Normal 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;
|
||||
}
|
2
examples/euclid/euclid.stdin.txt
Normal file
2
examples/euclid/euclid.stdin.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
1071
|
||||
1029
|
4
examples/euclid/euclid.stdout.txt
Normal file
4
examples/euclid/euclid.stdout.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
Please enter the first number:
|
||||
Please enter the second number:
|
||||
|
||||
euclid(1071, 1029) = 21
|
Reference in New Issue
Block a user