修改文件结构。
This commit is contained in:
29
POP/08/Optional01.c
Normal file
29
POP/08/Optional01.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
|
||||
bool checkDigits(int chicken, int rabbit) {
|
||||
bool digits[6] = {0};
|
||||
int num = chicken*1000 + rabbit;
|
||||
while (num > 0) {
|
||||
if (num % 10 > 6 || digits[num % 10]) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
digits[num % 10] = true;
|
||||
num /= 10;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int count = 50;
|
||||
for (count = 50; count < 250; count++) {
|
||||
if (checkDigits(count * 2, count * 4)) {
|
||||
printf("There are %d chickens and rabbits. %d chicken legs, %d rabbit legs.", count, count*2, count*4);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user