一道关于c语言的基础题

来源:百度知道 编辑:UC知道 时间:2024/06/07 12:19:54
定义函数 int f(int x)判断x是否为奇数,是则函数返回1,否则为0.

麻烦大家教教我,谢谢了。

#include "stdio.h"

int f(int a )
{
if(a%2==0) return 0;
else return 1;

}
void main()
{int a,b;
scanf("%d",&a);
b=f(a);
if(b==0) printf("the number is oushu");
else printf("the number is jishu");

}

#include "stdio.h"
#include "stdlib.h"
int f(int a )
{
if(a%2==0) return 0;
else return 1;

}
int main()
{int a,b;
scanf("%d",&a);
b=f(a);
if(b==0) printf("the number is oushu");
else printf("the number is jishu");
system("pause");
}

int f(int x)
{
return (x%2);
}

int f(int x)
{
if(x%2==0) return 0;
else return 1;
}

int f(int x)
{
if (x % 2 == 0)
{
return 1;
}
return 0;
}可以吗?

都可以吧。