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

View File

@@ -0,0 +1,45 @@
int modulo(int n, int k) {
return (n - k * (n / k));
}
bool is_palindrome(int original) {
int reversed;
int remainder;
int to_check;
reversed = 0;
to_check = original;
while (to_check != 0) {
remainder = modulo(to_check, 10);
reversed = reversed * 10 + remainder;
to_check = to_check / 10;
}
if (original == reversed) {
return true;
} else {
return false;
}
}
int main() {
int input;
print("Please enter a number:");
input = read_int();
print_nl();
bool result = is_palindrome(input);
print_int(input);
if (result) {
print(" is a palindrome.");
} else {
print(" is not a palindrome.");
}
print_nl();
return 0;
}

View File

@@ -0,0 +1 @@
4321234

View File

@@ -0,0 +1,2 @@
Please enter a number:
4321234 is a palindrome.