怎么Dev C++会显示错误?请指出并更正,谢

#include<iostream>
main()
{
float s;
float cost;

printf("请输入里程 \n");
scanf("%f \n",&s);

if(s<0)
printf("输入错误 \n")
else if(s>=0 and s<2)
cost=2
else if(s>2)
cost=7+2*(x-2)

printf("价钱是%.3f \n");

system("pause");
}

#include<iostream>
void main()
{
float s;
float cost;

printf("请输入里程 \n");
scanf("%f",&s);//这里的空格和\n去掉,输入的地方不需要的

if(s<0)
printf("输入错误 \n");//少分号
else if(s>=0 && s<2)//C语言里面的与是&&
cost=2;//少分号
else if(s>2)
cost=7+2*(s-2);//少分号,s写成了x

printf("价钱是%.3f \n",cost); //加上cost

system("pause");
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-02-24
头文件应该是stdio.h 你下面用的输入和输出时c中的
头文件却是c++中的
第2个回答  2012-02-24
错误N多·一楼正解·
C++的输入输出流可以用cin>> 和cout<<
第3个回答  2012-02-24
首先:
请您把头文件改成#include<stdio.h>,谢谢!
相似回答