#include<stdio.h>
int main(){
int max(int a,int b);
int a=19,b=34;
int m=max(a,b);
printf("m=%d",m);
return 0;
}
int max(int a,int b){
int c;
if(a>b)c=a;
else c=b;
return c;
}
编写函数Fum1实现上式,并返回函数值。在main函数调用Fum1函数,接受输入的x值,并输出函数值,例如:输入3.5,输出6.
#include<stdio.h>
int main(){
int Fun1(double);
double x;
scanf("%lf",&x);
double y;
y=Fun1(x);;
printf("%lf",y);
return 0;
}
int Fun1(double x){
double c;
if(x>=10)c=2*x;
else
if(x<1)c=x;
else c=2*x-1;
return c;
}