三天打鱼两天晒网 c语言
时间: 2023-11-07 13:59:09 浏览: 67
这里提供一种基于C语言的实现方法:
```
#include <stdio.h>
int main() {
int day = 1;
int fish_count = 0;
while (day <= 365) {
if (day % 5 == 4 || day % 5 == 0) { // 第4天和第5天晒网
printf("Today is day %d, we are resting.\n", day);
} else { // 其他天数打鱼
printf("Today is day %d, we are fishing.\n", day);
fish_count++;
}
day++;
}
printf("In a year, we have caught %d fish.\n", fish_count);
return 0;
}
```
这个程序会模拟一年的时间,每天判断是打鱼还是晒网,最终输出这一年打到的鱼的数量。其中,第4天和第5天是休息日,不打鱼。