很简单的编程

来源:百度知道 编辑:UC知道 时间:2024/06/23 21:39:43
就是华氏和摄氏度的转化,输出2行,从10到20的转化,打假帮我看下,这样为什么不行啊
#include<stdio.h>
void main()
{
int f;
float c;
printf("f c\n");
for(f=10;f<=20;f++){
c=(5.0/9)*(f-32);
printf("%d%.2f\n",f,c);
}
}

错误提示
--------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
d:\1\1.cpp(12) : fatal error C1010: unexpected end of file while looking for precompiled header directive
执行 cl.exe 时出错.

1.exe - 1 error(s), 0 warning(s)
将第二行全角的小括号换成英文半角的就好了
也就是把void main()换成void main()

这个我在检查的时候改过了,还是出现上面的提示,郁闷了

将第二行全角的小括号换成英文半角的就好了
也就是把void main()换成void main()

更新回答:有两种解决方法

1、在文件开头添加:
#include "stdafx.h"

2、参考http://blog.csdn.net/lipond/archive/2008/03/03/2143338.aspx

不会吧,同样的程序在我的机子上能运行呀
你看一下最后一行有没有什么字符之类的

OH MY GOD>>

printf("f c\n"); %f %c 少了%

没错啊
f c
10-12.22
11-11.67
12-11.11
13-10.56
14-10.00
15-9.44
16-8.89
17-8.33
18-7.78
19-7.22
20-6.67