5-2.cpp

来自「为C++学习者」· C++ 代码 · 共 37 行

CPP
37
字号
#include<iostream.h>
#include<iomanip.h>
void readdata (float score[10])
{
	int i;
	cout<<"enter 10 student's scores:\n";
	for(i=0;i<10;i++)
		cin>>score[i];
	return ;
}
float aver(float score[10])
{
	float sum;
	int i;
	for(sum=0,i=0;i<10;i++)
		sum=sum+score[i];
	return(sum/10);
}
void print(float score[10],float ave)
{
	int i;
	cout<<"the scores which are below the average:";
	for(i=0;i<10;i++)
		if(score[i]<ave)cout<<score[i];
	return ;
}
void main()
{
	void readdata(float score[10]);
	float aver(float score[10]);
	void print(float score[10],float ave);
	float ave,score[10];
	readdata(score);
	ave=aver(score);
	cout<<"average="<<ave<<endl;
	print(score,ave);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?