你那个if else没有配合
if后边没有大括号的时候只能跟一条语句,你的后边跟了两条,所以要用大括号括起来改成这样:
if(x>0)
{
x=x+y;
printf("%f\n",x);
}
else
printf("%f\n",x);
或者改成
if(x>0)
x=x+y;
printf("%f\n",x);
将if else之间的两个语句用{}包裹即可
{
x = x + y;
printf(……)
望采纳
#include<stdio.h>
int main()
{
float x,y;
scanf("%f%f",&x,&y);
if(x>0)
{
x=x+y;
printf("%f\n",x);
}
else
{
printf("%f\n",x);
}
return 0;
}
这样就没问题了