读书人

大家帮忙看下 这个程序那里出有关问题

发布时间: 2012-02-05 12:07:14 作者: rapoo

大家帮忙看下 这个程序那里出问题了?
//777
#include <iostream>
#include <iomanip>
using namespace std;

viod show1(double [][b]);
double pj(double [][b]);
double max(double [][b]);
main()
{
const int a=2;
const int b=3;
double A[a][b]={12.1,14.2,15.2,11.4,15.2,14.9};
cout<<"数组A是:"<<endl;
show1(A);
cout<<"数组A的平均值是:"<<pj(A)<<endl;
cout<<"数组A的最大值是:"<<max(A)<<endl;
return 0;
}
//函数show()的定义
viod show1(double q[][b])
{
for(int i=0;i<a;i++)
{
for(int y=0;y<b;y++)
cout<<setw(5)<<q[i][y]<<endl;
}
return 0;
}
//函数pj()的定义
double pj(double n[][b])
{
double sum=0;
double pj1;
for(int i=0;i<a;i++)
{
for(int y=0;y<b;y++)
sum+=n[i][y];
}pj1=sum/double(6);
return pj1;
}
//函数max()的定义
double max(double m[][b])
{double max1=m[0][0];
for(int i=0;i<a;i++)
for(int y=0;y<b;y++)
{
if(max1<m[i][y])
max1=m[i][y];
}
return max1;
}

[解决办法]

C/C++ code
viod show1(double [][b]);
[解决办法]
C/C++ code
#include  <iostream> #include  <iomanip> using namespace std; const int a=2; const int b=3; void show1(double q[][b]);double pj(double n[][b]) ;double max(double m[][b]) ;main() {         double A[a][b]={12.1,14.2,15.2,11.4,15.2,14.9};     cout <<"数组A是:" <<endl;     show1(A);     cout <<"数组A的平均值是:" <<pj(A) <<endl;     cout <<"数组A的最大值是:" <<max(A) <<endl;     return 0; } //函数show()的定义 void show1(double q[][b]) {     for(int i=0;i <a;i++)     {         for(int y=0;y <b;y++)             cout <<setw(5) <<q[i][y] <<endl;     }     return ; } //函数pj()的定义 double pj(double n[][b]) {     double sum=0;     double pj1;     for(int i=0;i <a;i++)     {         for(int y=0;y <b;y++)             sum+=n[i][y];     }pj1=sum/double(6);     return pj1; } //函数max()的定义 double max(double m[][b]) {    double max1=m[0][0];     for(int i=0;i <a;i++)         for(int y=0;y <b;y++)         {             if(max1 <m[i][y])                 max1=m[i][y];         }         return max1; }
[解决办法]
C/C++ code
#include  <iostream> #include  <iomanip> using namespace std; const int a=2;   //放前面const int b=3; void show1(double [][b]);   //void,不是vioddouble pj(double [][b]); double max(double [][b]); int main() {  double A[a][b]={12.1,14.2,15.2,11.4,15.2,14.9};  cout <<"数组A是:" <<endl;  show1(A);  cout <<"数组A的平均值是:" <<pj(A) <<endl;  cout <<"数组A的最大值是:" <<max(A) <<endl;  return 0; } //函数show()的定义 void show1(double q[][b])   //一样{ for(int i=0;i <a;i++) {   for(int y=0;y <b;y++)      cout <<setw(5) <<q[i][y] <<endl;    } //return 0;   //没有返回值} //函数pj()的定义 double pj(double n[][b]) {  double sum=0;  double pj1; for(int i=0;i <a;i++) {   for(int y=0;y <b;y++)     sum+=n[i][y];  }pj1=sum/double(6);  return pj1; } //函数max()的定义 double max(double m[][b]) {double max1=m[0][0]; for(int i=0;i <a;i++)    for(int y=0;y <b;y++)      {      if(max1 <m[i][y])      max1=m[i][y];      } return max1; } 

读书人网 >C++

热点推荐