第五课。

This commit is contained in:
unlockable
2022-10-15 20:40:43 +08:00
parent c3608c3f89
commit bf3b5851d3
8 changed files with 184 additions and 0 deletions

34
05/Optional02.c Normal file
View 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;
}