1.devise a function min(x,y)that returns the smaller of two double values,and test the function with a simple driver,
2.write a program that inputs a series of integers (say,3,integers)and passes them one at a time to function even which uses the remainder operator (modulo division operator)to determine if an integer is even .the function should take an integer argument and return 1 if the integer is even and 0 otherwise.
能告诉我怎么编这2个程序嘛 谢谢 有追加
追答if(a%2)
printf("not even number!\n");
else
printf(" even number!\n");
能帮忙写下这2个程序吗 谢谢
追答//1
#include
double min(double a,double b)
{
return a>b?b:a;
}
void main()
{
printf("min=%f\n",min(1.0,2.0));
}
//2
#include
int even(int a)
{
return a%2==0;
}
void main()
{
int a;
for(int i=0;i<3;i++)
{
scanf("%d",&a);
if(even(a))
printf("even number!\n");
else
printf("not even number!\n");
}
}