天氣日記一天記一個字母,存在 week 裡:S 晴、R 雨、C 陰。數出三種天氣各幾天,最後顯示的那一行已經寫好了。
Sunny 3, rainy 3, cloudy 1
#include <stdio.h>
int main(void) {
char week[] = "SRCSRRS";
int sunny = 0, rainy = 0, cloudy = 0;
for (int i = 0; week[i] != '\0'; i++) {
// 在這裡寫:按字母給 sunny、rainy 或 cloudy 加 1
}
printf("Sunny %d, rainy %d, cloudy %d\n", sunny, rainy, cloudy);
return 0;
}
寫好了先點「執行」試試示例,沒問題再點「提交」。