第二次上机指导

来源:互联网 发布:卡盟主站域名大全 编辑:程序博客网 时间:2024/05/22 09:06

姓名:尉桢   学号:120705142  班级:电子信息工程1班

任务1

//********//Code by 尉桢 120705142//***********#include<stdio.h>int main(){int fahr, celsius;int lower, upper, step;lower=100;upper=1000;step=100;fahr=lower;printf("尉桢,120705142\n", "");while (fahr<=upper) {celsius=6.21*fahr;printf("%d %d\n",  fahr, celsius);fahr=fahr+step;}return 0 ;}

结果

感悟

     第一次自己对照一个程序自己动手写,刚开始觉得很难,手忙脚乱的,但经过一段时间的动手操作,感觉还行,当程序运行出来的时候,那种感觉,不知道怎么形容,反正就是很开心,很喜欢。

任务2

//**********//Code by 尉桢 120705142//********#include<stdio.h>int main(){int  f;    //摄氏温度与华氏温度int  c;    //摄氏温度int  lower=0;     //温度表的下限int  upper=300;   //温度表的上限int  step=20;      //步长f=lower;printf("尉桢,120705142\n", "");while (f<=upper){//*************//摄氏与华氏温度的转换公式//C=(5/9)(F-32)//*************c=(5/9)*(f-32);printf("%d\t%d\n",  f,c);f=f+step;}return 0;}


 

结果

了解int和float变量类型

//**********//Code by 尉桢 120705142//********#include<stdio.h>int main(){float  f;      //摄氏温度与华氏温度float  c;      //摄氏温度float  lower=0;      //温度表的下限float  upper=300;    //温度表上限float  step=20;      //步长f=lower;printf("尉桢,120705142\n", "");while (f<=upper){//*************//摄氏与华氏温度的转换公式//C=(5/9)(F-32)//*************c=(5.0/9.0)*(f-32.0);printf("%f\t%f\n",  f,c);f=f+step;}return 0;}


 

结果

原创粉丝点击