网友您好, 请在下方输入框内输入要搜索的题目:
下列给定程序中,函数proc的功能是:根据输入的3个边长(整型值),判断能否构成三角形:若能构成等边三角形,则返回3;若是等腰三角形,则返回2;若能构成三角形则返回 1;若不能,则返回0。 例如,输入3个边长为3,4,5,实际输入时,数与数之间以Enter键分隔而不是逗号。请修改程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: include<stdio.h> include<math.h> int proc(int a,int b,int c) { if(a+b>c&&b+c>aa+c>b) { if(a= =b&&b= =c) //****found**** return 1; else if(a= =b||b= =c||a= =c) return 2; //****found**** else return 3; } else return 0; } void main { int a,b,C,shape; printf("\nlnput a,b,C:"); scanf("%d%d%d",&a,&b,&c); printf("\na=%d,b=%d,c=%d\n",a,b,c); shape=proc(a,b,c); printf("\n\nThe shape:%d\n",shape); }
参考答案
更多 “ 下列给定程序中,函数proc的功能是:根据输入的3个边长(整型值),判断能否构成三角形:若能构成等边三角形,则返回3;若是等腰三角形,则返回2;若能构成三角形则返回 1;若不能,则返回0。 例如,输入3个边长为3,4,5,实际输入时,数与数之间以Enter键分隔而不是逗号。请修改程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: includestdio.h includemath.h int proc(int a,int b,int c) { if(a+bc&b+caa+cb) { if(a= =b&b= =c) //****found**** return 1; else if(a= =b||b= =c||a= =c) return 2; //****found**** else return 3; } else return 0; } void main { int a,b,C,shape; printf("\nlnput a,b,C:"); scanf("%d%d%d",a,b,c); printf("\na=%d,b=%d,c=%d\n",a,b,c); shape=proc(a,b,c); printf("\n\nThe shape:%d\n",shape); } ” 相关考题
![瑞牛题库 章节练习 历年真题 模拟试卷](http://assets.51tk.com/51_sidebar_right_index.jpg)