类型:转载 责任编辑:asp.net 日期:2007/05/23
热门软件下载:
1。
//*****************************************
//** ch1_3.1.cpp **
//*****************************************
#include<iostream.h>
#include<math.h>
double max(double x,double y,double z);
void main()
{
double a,b,c,d;
cout<<"input three numbers:\n";
cin>>a>>b>>c;
d=max(a,b,c);
cout<<"the squart of maximum="<<sqrt(d)<<endl;
}
double max(double x,double y,double z)
{
if(x>y)
return x;
if(y>z)
return y;
else
return z;
}
2。
//*******************************************
//** ch1_3.1.1.cpp **
//*******************************************
#include<iostream.h>
#include<math.h>
double max(double x,double y,double z);
{
if(x>y)
return x;
if(y>z)
return y;
else
return z;
}
void main()
{
double a,b,c,d;
cout<<"input three numbers:\n";
cin>>a>>b>>c;
d=max(a,b,c);
cout<<"the squart of maximum="<<sqrt(d)<<endl;
}
•Compiling NONAME04.CPP:
Error NONAME04.CPP 11: Declaration terminated incorrectly
第一个程序可以通过,怎么第二个不可以通过呢;我用if语句对吗?谢谢:
网友回答:
double max(double x,double y,double z); //这行后面的分号去掉
{
if(x>y)
return x;
if(y>z)
return y;
else
return z;
}
#include<iostream.h>
#include<math.h>
double max(double x,double y,double z)//原程序这里
{
if(x>y)
return x;
if(y>z)
return y;
else
return z;
}
void main()
{
double a,b,c,d;
cout<<"input three numbers:\n";
cin>>a>>b>>c;
d=max(a,b,c);
cout<<"the squart of maximum="<<sqrt(d)<<endl;
}
double max(double x,double y,double z);
这行多了;这个吧, 这是定义和声明一起的呀!!
定义和声明一起也不是这样吧!应当是:
double max(double x,double y,double z);
double max(double x,double y,double z)
{
if(x>y)
return x;
if(y>z)
return y;
else
return z;
}
原因就是他们说的多了一个;号.
如果是n多数
在一个数组里
那你就遍历一下
然后排序就可以了
qsort()