程序修改 : 请 指出 程序中的错误, 并改正 ,使它能得出正确的结果。 注意 : 1 、 请将modi.c文件,
下列给定程序中,函数proc的功能是:根据输入的:个边长(整型值),判断能否构成三角形:若能构成等边三角形,则返回3;若是等腰三角形,则返回2;若能构成三角形则返回l;若不能,则返回0。 例如,输入3个边长为3,4,5,实际输入时,数与数之间以Enter键分隔而不是逗号。 请修改程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: include include int proc(int a,int b,int c) { if(a+b>c&&b-c>a&&a+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("\nInput 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的功能是:判断字符ch 是,与str所指字符串中的某个字符相同;若相同,则什么也不做,若不同,则将其插在串的最后。请修改程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: include include include include //****found**** void proc(char str,char ch) { while(*str &&*str!=ch)str++; //****found**** if(*str==ch) { str[0]=ch; //****found**** str[1]=0: } } void main { char str[81],ch; system("CLS"); printf("\nPlease enter a string:"); gets(str); printf("\n Please enter the character to search:"); ch=getchar; proc(str,ch); printf("\nThe result is%s\n",str); }
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!