实验中的程序参考答案实验中的程序参考答案.docVIP

  • 242
  • 0
  • 约2.04万字
  • 约 17页
  • 2017-01-01 发布于贵州
  • 举报

实验中的程序参考答案实验中的程序参考答案.doc

实验中的程序参考答案实验中的程序参考答案

实验三:顺序结构程序设计 1.编写一个程序,输入一个字符,输出它的前后邻居 #include stdio.h void main() { char c1; printf(“Input a character: ”); c1=getchar(); putchar(c1-1); putchar(‘\t’); putchar(c1+1); putchar(‘\n’); } 2.编写一个程序,求三角形的面积。其中,a、b、c为三角形的三条边,s=(a+b+c)/2,面积为area= #include stdio.h #include math.h void main() { float a,b,c,s,area; printf(“Input a,b,c: ”); scanf(“%f,%f,%f”,a,b,c); s=(a+b+c)/2; area=sqrt(s*(s-a)*(s-b)*(s-c)); printf(“area=%f\n”,area); } 3.编写一个程序,求摄氏温度。公式:c=5*(f-32)/9 #include stdio.h void main() { float f,c; printf(“Input f: ”); scanf(“%f”,f); c=5*(f-32)/9; printf(“c=%f\n”,c)

文档评论(0)

1亿VIP精品文档

相关文档