例如,若t1=7,t2=5,t3=6,t4=4,n=10,则总共可听到28次鞭炮声。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include
/**********found**********/
#define OK(i, t, n) ((___1___%t==0) && (i/t int fun(int t1, int t2, int t3, int t4, int n) {int count, t , maxt=t1; if (maxt < t2) maxt = t2; if (maxt < t3) maxt = t3; if (maxt < t4) maxt = t4; count=1; /* 给count赋初值 */ /**********found**********/ for(t=1; t< maxt*(n-1); ___2___) { if(OK(t, t1, n) || OK(t, t2, n)|| OK(t, t3, n) || OK(t, t4, n)) count++; } /**********found**********/ return ___3___; } main() {int t1=7, t2=5, t3=6, t4=4, n=10, r; r = fun(t1, t2, t3, t4, n); printf("The sound : %d\n", r); } 解题答案: /**********found**********/ for(t=1; t< maxt*(n-1); t++) /**********found**********/ return count; ****************************************** [NextPage] 二、改错题:给定程序MODI1.C中函数fun的功能是: 根据输入的三个边长(整型值), 判断能否构成三角形; 构成的是等边三角形, 还是等腰三角形。若能构成等边三角形函数返回3,若能构成等腰三角形函数返回2, 若能构成一般三角形函数返回1, 若不能构成三角形函数返回0。 请改正函数fun中指定部位的错误, 使它能得出正确的结果。 注意: 不要改动main函数, 不得增行或删行, 也不得更改程序的结构! 给定源程序: #include #include /**************found**************/ void fun(int a,int b,int c) {if(a+b>c && b+c>a && a+c>b) { if(a==b && b==c) return 3; else if(a==b||b==c||a==c) return 2; /**************found**************/ else return 1 } else return 0; } 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 =fun(a,b,c); printf("\n\nThe shape : %d\n",shape); } 解题答案: /**************found**************/ int fun(int a,int b,int c) /**************found**************/ else return 1; ****************************************** [NextPage] 二、改错题:给定程序MODI1.C中函数fun的功能是: 根据输入的三个边长(整型值), 判断能否构成三角形; 构成的是等边三角形, 还是等腰三角形。若能构成等边三角形函数返回3,若能构成等腰三角形函数返回2, 若能构成一般三角形函数返回1, 若不能构成三角形函数返回0。 请改正函数fun中指定部位的错误, 使它能得出正确的结果。 注意: 不要改动main函数, 不得增行或删行, 也不得更改程序的结构! 给定源程序: #include #include /**************found**************/ void fun(int a,int b,int c) {if(a+b>c && b+c>a && a+c>b) { if(a==b && b==c) return 3; else if(a==b||b==c||a==c) return 2; /**************found**************/ else return 1 } else return 0; } 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 =fun(a,b,c); printf("\n\nThe shape : %d\n",shape); } 解题答案: /**************found**************/ int fun(int a,int b,int c) /**************found**************/ else return 1; ******************************************
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号 珠峰网 版权所有 All Rights Reserved
|