條件:明天下雨 敘述:帶雨傘
if(condition)
statement;
| 數值判斷 | 語法 |
|---|---|
| 大於 | > |
| 小於 | < |
| 等於 | == |
| 大於等於 | >= |
| 小於等於 | <= |
| 且 | && |
| 或 | || |
if (condition)
statement1;
else
statement2;
int main() {
int year;
scanf("%d", &year); // 輸入年份year
if (year%400 == 0 ) {
printf("%d是閏年\n", year);
}
else if( (year%4 == 0) && (year%100 != 0)){
printf("%d是閏年\n", year);
}
else {
printf("%d不是閏年\n", year);
}
}
while (condition)
statement1;
就跟 if 一樣 回家自己想想囉