Add student example inputs
This commit is contained in:
29
examples/is_square/is_square.mc
Normal file
29
examples/is_square/is_square.mc
Normal file
@@ -0,0 +1,29 @@
|
||||
/* is_squared returns true if a number is the square of any integer */
|
||||
|
||||
bool is_square(int n)
|
||||
{
|
||||
int i = 0;
|
||||
while(i*i < n){
|
||||
if(i*i == n){
|
||||
return true;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
print("Please enter a number: ");
|
||||
print_nl();
|
||||
int n;
|
||||
n = read_int();
|
||||
if(is_square(n)){
|
||||
print("Yes");
|
||||
}
|
||||
else
|
||||
{
|
||||
print("No");
|
||||
}
|
||||
print_nl();
|
||||
}
|
1
examples/is_square/is_square.stdin.txt
Normal file
1
examples/is_square/is_square.stdin.txt
Normal file
@@ -0,0 +1 @@
|
||||
16
|
2
examples/is_square/is_square.stdout.txt
Normal file
2
examples/is_square/is_square.stdout.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Please enter a number:
|
||||
No
|
Reference in New Issue
Block a user