第五课。
This commit is contained in:
34
05/Optional02.c
Normal file
34
05/Optional02.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int inCircle(int centerX, int centerY, int posX, int posY) {
|
||||
int x_distance = 0, y_distance = 0;
|
||||
x_distance = centerX - posX;
|
||||
y_distance = centerY - posY;
|
||||
if (x_distance * x_distance + y_distance * y_distance <= 1) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
int pos_x = 0 , pos_y = 0;
|
||||
scanf("%d %d", &pos_x, &pos_y);
|
||||
if (inCircle(2, 2, pos_x, pos_y)) {
|
||||
printf("10m");
|
||||
}
|
||||
else if (inCircle(-2, 2, pos_x, pos_y)) {
|
||||
printf("9m");
|
||||
}
|
||||
else if (inCircle(-2, -2, pos_x, pos_y)) {
|
||||
printf("8m");
|
||||
}
|
||||
else if (inCircle(2, -2, pos_x, pos_y)) {
|
||||
printf("7m");
|
||||
}
|
||||
else {
|
||||
printf("0m");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user