当前位置:文档之家› 以下程序的功能是按顺序读入10名学生

以下程序的功能是按顺序读入10名学生

以下程序的功能是:按顺序读入10名学生4门课程的成绩,计算出每个学生的平均分数并输出,程序如下:
以下程序的功能是:按顺序读入10名学生4门课程的成绩,计算出每个学生的平均分数并输出,程序如下:#include<iostream>using namespace std;int main() { int n,k;float score,sum,ave;sum = 0.0;for(n = 1;n <=10;n++) { for(k =1;k <=4;k++) { cin>>score;sum += score;} ave=sum/4.0;cout<<"NO."<<n<<"ave:"<<ave<<end1;} return 0;} 上述程序运行后结果不正确,调式中发现有一条语句出现在程序中的位置不正确。

这条语句是非曲直()。

A.sum=0.0;
B.sum+=score;
C.ave= sum/4.0
D.cout<<"NO."<<n<<"ave:"<<ave<<end1;
有以下程序: #include <iostream> using namespace std; char *x[]={"First", "Second", "Third" }; void f(char *z[ ]) { cout<<*z++<<end1; } int main ( ) { char **y; y=x; f(y); return 0; }
A.产生语法错误
B.First
C.Secpnd
D.Third
以下程序的输出结果是( )。

#include <iostream> using namespace std; int f(int b[],int m, int n) { int i,s = O; for(i = m;i<n;i+=2) s+=b [i]; return s; } int main ( ) { int x a[] = {1,2,3,4,5,6,7,8,9}; x = f(a,3,7); cout<<x<<end1; return 0; }
A.10
B.18
C.8
D.15
有以下程序: #include <iostream> using namespace std; class MyClass { int m; publ i c: static int n; MyClass ( ) { m = 0; } void setvalue() { m++; n++; } void output () { cout<<"m="<<m<<'' , n="<<n<<end1; } }; int MyClass :: n=0; int main() { MyClass obj1, obj2; obj1.setvalue(); objl.output(); obj2.setvalue( ); obj2.output(); return 0; }
A.m= 1 ,n= 1 <换行>m= 1 ,n=1
B.m= 1 ,n= 1 <换行>m=1 ,n=2
C.m=1,n=1<换行>m=2,n=1
D.m=1,n=1<换行>m=2,n=2。

相关主题