#include "stdafx.h"
//#include <stdio.h>
#define LOWER 0 /* lower limit of table */
#define UPPER 300 /* upper limit */
#define STEP 20 /* step size */
/* print Fahrenheit-Celsius table */
int main()
{
int fahr;
for (fahr = LOWER; fahr <= UPPER; fahr = fahr + STEP)
printf("%4d %6.2f\n", fahr, (5.0/9.0)*(fahr-32));//按照浮点数打印,至少6个字符宽度,小数点后有两位小数
}
打印华氏温度-摄氏温度对照表,注意几点:
1,VS2010中include <stdio.h>没有也能编译成功,VC++6.0中就不行;
2,VS2010中main函数不能默认为int,也就是说main函数前必须加上int 等类型符,VC++6.0中可以省略int;
有关VS2010和VC++6.0的区别,正在了解中