-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest8
61 lines (46 loc) · 1.01 KB
/
test8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
6-12 判断奇偶性(10 分)
本题要求实现判断给定整数奇偶性的函数。
函数接口定义:
int even( int n );
其中n是用户传入的整型参数。当n为偶数时,函数返回1;n为奇数时返回0。注意:0是偶数。
裁判测试程序样例:
#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.
___________________________________________________________________________________________________________________________________________
#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;
}
int even(int n){
if(n%2==0)
return 1;
else
return 0;
}