|
发表于 2006-7-12 17:08:41
|
显示全部楼层
# include <iostream.h>
# include <iomanip.h>
void pr_scores(float scores[ ]); //express the prints and average six test scores
void calr_average(float, float scores,char s_name[ ]);
int main ( )
{
char s_name[ ] ="Tri star University";
float scores[6] = {54.6,48.6, 36.6,66.6,72.6, 78.6};
float average =0.0;
// call all function to print array.
pr_scores(scores);
void calr_average(float,scores, s_name); // void calr_average(float acerage,float * scores,char * s_name);
return0;
}
//the frist portotype.
void pr_scores (float scores[6])
{
int ctr ;
cout << "Here are your scores: ";
for (ctr=0;ctr<6; ctr++)
cout << setprecision(2) << scores[ctr] <<"\n";
return;
}
void calr_average(float acerage, float scores[6], char s_name[ ]); // void calr_average (float,float #, char #])
{
int ctr;
// float * scores=scores;
// char * s_name = s_name;
for (ctr=0;ctr< 6;ctr++)
{
average += scores[ctr];
}
//computer the average;
average /= float(6);
cout << "At" <<s_name<<", your class average is "<< setprecision(2) << average ;
return;
}
我 这个可错得有点多哦 |
|