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

43
examples/gcd/gcd.mc Normal file
View File

@@ -0,0 +1,43 @@
/* calulcate modulo */
int mod(int a, int b){
return a-(a/b*b);
}
/* calulate greatest common divisor */
int gcd(int x, int y){
int c;
if (x < 0){
x = -x;
}
if (y < 0){
y = -y;
}
while (y != 0) {
c = mod(x, y);
x = y;
y = c;
}
return x;
}
int main() {
int a;
int b;
print("Please enter the first number: ");
print_nl();
a = read_int();
print("Please enter the second number: ");
print_nl();
b = read_int();
int res = gcd(a,b);
print("The greatest common divisor is: ");
print_int(res);
print_nl();
return 0;
}

View File

@@ -0,0 +1,2 @@
10
15

View File

@@ -0,0 +1,3 @@
Please enter the first number:
Please enter the second number:
The greatest common divisor is: 5