北京交通大学黄宇黄宇老师C语言第一次作业.docVIP

  • 8
  • 0
  • 约1.61千字
  • 约 6页
  • 2018-05-04 发布于河南
  • 举报

北京交通大学黄宇黄宇老师C语言第一次作业.doc

北京交通大学黄宇黄宇老师C语言第一次作业.doc

注:此程序环境为Microsoft Visual Studio 2010 实验目的1:输入三角形的三个边长a, b, c, 求三角形的面积 程序设计: # include stdio.h # include math.h int main(void) { float a,b,c,p,s; scanf(%f,%f,%f,a,b,c); p=(a+b+c)/2; s=sqrt(p*(p-a)*(p-b)*(p-c)); printf(%7.2f\n,s); return 0; } 运行结果: 程序二目的:假设变量a、b和c均为整形,借助中间变量t把a、b和c中的值进行交换,即:把b中的值给a,把c中的值给b,把a中的值给c。例如:交换前,a=10、b=20、c=30;交换后,a=20,b=30,c=10 程序设计: # include stdio.h # include math.h int main(void) { int a,b,c,t; scanf(%d,%d,%d,a,b,c); t=b; b=c; c=a; a=t; printf(%d,%d,%d,a,b,c); return 0; } 程序三目的:.输入一个华氏温度,要求输出摄氏温度。 程序设计: # include stdio.h # include math.h int m

文档评论(0)

1亿VIP精品文档

相关文档