问答题

请编写一个函数fun(int score [][3],int num),该函数返回有一门成绩以上课程成绩在85分以上,其余课程成绩不低于70分的人数。数组score按行存放num名考生各自的三门期末考试成绩。 注意:部分源程序已存在文件test31_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。 程序输出结果如下: 3 文件test31_2.cpp清单如下: #include <iostream.h> int fun(int score[] [3],int num) { } void main ( ) { int score[4] [3]={{70,89,92},{70,76,93},(80,86,98},{65,73,45}); cout<<fun(score,4)<<end1; }

【参考答案】

int fun(int score[] [3],int num) { int total=0; int flag=0......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)
热门 试题

问答题
使用VC6打开考生文件夹下的工程test31_3。此工程包含一个test31_3.cpp,其中定义了可以动态分配的字符串类,但该类的定义并不完整。请按要求完成下列操作,将程序补充完整。(1)定义类tstring的私有数据成员length和p,它们分别是血型的数据和字符型的指针,其中length表示一个字符串的长度。请在注释“ **1**”之后添加适当的语句。(2)完成类tstring的构造函数,使length等于字符串m的长度,并申请由指针p指向的length长的字符型空间,将m所指的字符串复制到该空间。请在注释“ **2**”之后添加适当的语句。(3)完成类tstring的成员函数strcopy(tstringn)的定义,该函数将对象n的值(包括字符串长度和字符串本身)复制给调用该函数的对象(对象n的字符串长度任意)。请在注释“ **3**”之后添加适当的语句。(4)完成类tstring的友元函数strlink(tstring m,tstring n)的定义,该函数将可动态分配的字符串类对象m和n的字符串成员连接在一起(对象m和n的字符串长度任意),并返回该串。请在注释“ **4**”之后添加适当的语句。注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。程序输出结果如下:hello the world!源程序文件test31_3.cpp清单如下:#include<iostream.h>#include<conio.h>#include <string.h>class tstring{public: ** 1 **tstring(char *m){ ** 2 **strcpy(p,m);}void strcopy(tstring n);friend char *strlink(tstring m,tstring n);};void tstring::strcopy(tstring n){ ** 3 **char *q;q=new char[length];strcpy(q,tstring::p);q=strcat(tstring::p,n.p);tstring::p=q;tstring::length=strlen(tstring::p);}char *strlink(tstring m, tstring n){int length=strlen(m.p)+strlen(n.p);char *p; ** 4 **strcpy(p,m.p);p=strcat(p,n.p);return p;}void main ( ){tstring a( hello );tstring b( the world );tstring c( ! );a.strcopy(b);cout<<strlink(a,c)<<end1;}