|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include <stdio.h>
- void main()
- {
- int s,c;
- float p,w,d,f;
-
- scanf("%f,%f,%d",&p,&w,&s");
-
- if (s>=3000);
- {
- c=12;
- }
- else
- {
- c=s/250;
- }
- switch(c)
- {
- case 0:
- d=0;
- break;
- case 1:d=2;break;
- case 2:
- case 3:d=5;break;
- case 4:
- case 5:
- case 6:
- case 7:d=8;break;
- case 8:
- case 9:
- case 10:
- case 11:d=10;break;
- }
- f=p*w*s*(1-d/100.0);
- printf("your price=%15.4f\n",f);
-
- }
复制代码
报错如下:
--------------------Configuration: jj - Win32 Debug--------------------
Compiling...
jj.c
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\jj\jj.c(7) : error C2001: newline in constant
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\jj\jj.c(7) : error C2143: syntax error : missing ')' before 'string'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\jj\jj.c(13) : error C2181: illegal else without matching if
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\jj\jj.c(34) : warning C4244: '=' : conversion from 'double ' to 'float ', possible loss of data
执行 cl.exe 时出错.
本帖最后由 jackz007 于 2022-11-21 15:20 编辑
- scanf("%f,%f,%d",&p,&w,&s); // 这一行(第7行)有错,已经改正(去掉第三个双引号)
- . . . . . .
- if (s>=3000) // 这一行(第9行)有错,已经改正(去掉了行末分号;)
复制代码
|
|