AC代码:
/*
Description
编写程序,输入x,输出y
y=x2+3x-4 (x≤5)
=X2-5x+7 (x>5) //此处为x的2次方
Input
一个整数x
Output
对应的y
Sample Input Copy
5
Sample Output Copy
36
*/
#include <stdio.h>
#include <math.h>
int main()
{
int x,y;
scanf("%d",&x);
if(x <= 5)
{
y = pow(x,2)+3*x-4;
printf("%d\n",y);
}
else
{
y = pow(x,2)-5*x+7;
printf("%d\n",y);
}
return 0;
}
//标程:
#include <stdio.h>
int main(void){
int x,y;
scanf ("%d",&x);
if (x<=5)
{
y=x*x+3*x-4;
}
else if (x>5)
{
y=x*x-5*x+7;
}
printf("%d",y);
return 0;
}