描述:
輸入年份,判斷該年份是平年還是閏年。普通閏年:年份數值為4的倍數,且不是100的倍數。世紀閏年:公曆年份是整百數,且是400的倍數。
正確解法一:
正確解法二://巢狀判斷,滿足條件即輸出判斷結果
#include
intmain()
else
printf
("the year %d is normal year.\n"
,year);}
else
printf
("the year %d is leap year.\n"
,year);}
else
printf
("the year %d is normal year.\n"
,year)
;return0;
}
或者://巢狀判斷,通過變數 leap, 實現「唯一」輸出「出口」
#include
intmain()
else leap=0;
}else leap=1;
}else leap=0;
if(leap==1)
else
printf
("the year %d is normal year.\n"
,year)
;return0;
}
#include
intmain()
else
printf
("the year %d is normal year.\n"
,year)
;return0;
}
程式設計每日一題 C程式設計 計算工資
描述 正確解法 include intmain else salary hour 50.00 else if hour 40 else salary hour 30.00 printf 2lf n salary return0 錯誤解法一 include intmain else salary ho...
C 每日一題
題目 給定乙個陣列 nums 和乙個值 val 你需要原地移除所有數值等於 val 的元素,返回移除後陣列的新長度。不要使用額外的陣列空間,你必須在原地修改輸入陣列並在使用 o 1 額外空間的條件下完成,oj鏈結.解析 我們來解析一下這個題目的做題思路,他的含義就是讓我們刪除掉陣列中的元素,然後將陣...
程式設計每日一題 C程式設計 逆序的三位數
問題描述 有多組資料,每組資料為乙個整型正三位數,當輸入一組資料時,程式輸出按位序逆序的數字。若輸入數字結尾為零時,輸出不應有前導的零 輸入格式 每個測試有多組資料,每組均為乙個三位的正整數 輸出格式 輸出按位序逆序的數 輸入樣例 輸出樣例 解法一 include intmain else prin...