本題要求實(shí)現(xiàn)判斷給定整數(shù)奇偶性的函數(shù)。
int even( int n );其中n
是用戶傳入的整型參數(shù)。當(dāng)n
為偶數(shù)時(shí),函數(shù)返回1;n
為奇數(shù)時(shí)返回0。注意:0是偶數(shù)。
裁判測試程序樣例:
#include <stdio.h>int even( int n );int main(){ int n; scanf("%d", &n); if (even(n)) PRintf("%d is even./n", n); else printf("%d is odd./n", n); return 0;}/* 你的代碼將被嵌在這里 */輸入樣例1:
-6輸出樣例1:
-6 is even.輸入樣例2:
5輸出樣例2:
5 is odd.int even( int n ){ if(n%2==0) return 1; else return 0;}
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注