编制程序,完成该数学表达式
1.2 当x<3时
f(x)= 10 当x=3时
2x+1 当x>3时
#include<bits/stdc++.h>
using namespace std;
float f(float x)
{
if(x<3) return 1.2;
if(x==3) return 10;
if(x>3) return 2*x+1;
}
int main()
{
float x;
cin>>x;
cout<<f(x);
}
#include <stdio.h>
float f(float x)
{
if(x<3)
{
return 1.2;
}
if(x==3)
{
return 10;
}
if(x>3)
{
return 2*x+1;
}
}
int main()
{
float n;
scanf("%f",&n);
printf("%f",f(n));
return 0;
}