我来我网
https://5come5.cn
 
您尚未 登录  注册 | 菠菜 | 软件站 | 音乐站 | 邮箱1 | 邮箱2 | 风格选择 | 更多 » 
 

2004



性别: 帅哥 状态: 该用户目前不在线
等级: 品行端正
发贴: 222
威望: 0
浮云: 1107
在线等级:
注册时间: 2006-09-25
最后登陆: 2011-10-25

5come5帮你背单词 [ bribery /'braibəri/ n. 行贿,受贿 ]


请教高手

#include<iostream>

const int MAX_NUMBER_SCORES = 10;

void fill_array(int a[], int size,int & number_used);

double compute_average(const int a[],int number_used);

void show_diffference(const int a[],int number_used);

int main()
{
   using namespace std;
    int score[MAX_NUMBER_SCORES], number_used;
  cout << "This program reads golf scores and show\n"
        << "How much each differs from the average.\n";
   cout << "Enter golf scores :\n";
   fill_array(score,MAX_NUMBER_SCORES,number_used);
   show_difference(score,number_used);
   return 0;
}
void fill_array(int a[], int size,int& number_used)
{
   using namespace std;
   cout << "Enter up to " << size <<"nonnegative whole number.\n"
        << "Mark the end of the list with a negative number .\n";
   int next,index=0;
   cin >> next;
   while ((next >= 0) && (index < size))
   {
       a[index] = next;
       index++;
       cin >> next;
   }
   number_used = index;
}
double computer_average(const int a[],int number_used)
{
   double total = 0;
   for(int index = 0; index < number_used; index++)
      total = total + a[index];
   if( number_used > 0)
   {
       return (total/number_used);
   }
   else
   {
       using namespace std;
       cout << "Error: number of elements is 0 in computer_average.\n"
            << "computer_average return 0.\n";
       return 0;
   }
}
void show_difference(const int a[],int number_used)
{
   using namespace std;
   double average = compute_average(a,number_used);
   cout << "Average of the " <<number_used
        << "scores = " << average <<endl
        << "The scores are :\n";
   for(int index = 0;index < number_used;index++)
       cout << a[index] <<"differs from average by "
          << (a[index] - average) << endl;
}






show_difference(score,number_used);(第十四行)







void show_difference(const int a[],int number_used)
{                                                     第五十五行


有什么问题啊
顶端 Posted: 2006-10-26 18:09 | [楼 主]
随风而飘





性别: 保密 状态: 该用户目前不在线
等级: 品行端正
发贴: 136
威望: 0
浮云: 1121
在线等级:
注册时间: 2006-06-04
最后登陆: 2009-04-14

5come5帮你背单词 [ pane /pein/ n. 窗格玻璃 ]


没注释......
顶端 Posted: 2006-10-26 18:15 | [1 楼]
我来我网·5come5 Forum » 程序员之家

Total 0.007897(s) query 6, Time now is:11-24 01:57, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号