第一次上机报告
姓名:周洋洋 学号:120705241 日期:20130314
华氏温度与摄氏温度对照程序
//***********************
//对fahr=0,20,...300
//打印华氏温度与摄氏温度对照表
//code by 周洋洋 120705241 20130308
//***********************
#include "stdafx.h"
int main()
{
int fahr,celsius;
int lower,upper,step;
lower=0; /*温度表的下限*/
upper=300; /*温度表的上限*/
step=20; /*步长*/
fahr=lower;
printf ("周洋洋,120705241\n","");
while (fahr<=upper){
celsius=5*(fahr-32)/9;
printf ("%d %d\n",fahr,celsius);
fahr=fahr+step;
}
return 0;
}
运行结果截图:
修改代码,将printf("%d %d\n改为printf("%d\t其运行程序为
//***********************
//对fahr=0,20,...300
//打印华氏温度与摄氏温度对照表
//code by 周洋洋 120705241 20130308
//***********************
#include "stdafx.h"
int main()
{
int fahr,celsius;
int lower,upper,step;
lower=0; /*温度表的下限*/
upper=300; /*温度表的上限*/
step=20; /*步长*/
fahr=lower;
printf ("周洋洋,120705241\n","");
while (fahr<=upper){
celsius=5*(fahr-32)/9;
printf ("%d\t %d\n",fahr,celsius);
fahr=fahr+step;
}
return 0;
}
修改后运行结果截图:
6-3程序:
// 6-3.cpp : 定义控制台应用程序的入口点。
//
/*源程序:exp6-3.cpp*/
#include "stdafx.h"
void main()
{
void swap(int x,int y);
int a,b;
a=2,b=6;
printf("调用前:a=%d,b=%d\n",a,b);
swap(a,b);
printf("调用后:a=%d,b=%d\n",a,b);
}
void swap(int x,int y)
{
int temp;
printf("交换前:x=%d,y=d\n",x,y);
temp=x;
x=y;
y=temp;
printf("交换后:x=%d,y=%d\n",x,y);
}
运行结果截图:
总结:可能教的晚了些,虽然第一次手忙脚乱,不过看到结果是还是很开心感谢各位高手的帮助,此致。