C语言程序设计第四次作业-选择结构(2).pdfVIP

  • 0
  • 0
  • 约4.34千字
  • 约 9页
  • 2022-11-28 发布于上海
  • 举报

C语言程序设计第四次作业-选择结构(2).pdf

C语⾔程序设计第四次作业-选择结构(2) (⼀)改错题 输出三⾓形的⾯积和周长,输⼊三⾓形的三条边a、b、c ,如果能构成⼀个三⾓形,输出⾯积area和周长 perimeter (保留2位⼩数);否则,输出“These sides do not correspond to a valid triangle”。 输⼊输出样例1: Enter 3 sides of the triangle: 5 5 3 area = 7.15 ; perimeter = 13.00 输⼊输出样例2 : Enter 3 sides of the triangle: 1 4 1 These sides do not correspond to a valid triangle 源程序(有错误的程序) #include stdio.h #include math.h int main(void) { double a,b,c; double area,perimeter,s; printf(Enter 3 sides of the triangle: ); scanf( %lf%lf%lf,a,b,c ); if( a + b c || b + c a || a + c b) s = ( a + b + c ) / 2; area = sqrt( s

文档评论(0)

1亿VIP精品文档

相关文档