首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

运作以后显示缺少函数标题 ,是什么意思

2012-10-23 
运行以后显示缺少函数标题 ,是什么意思?#include iostreamusing namespace stdstruct person{ char nam

运行以后显示缺少函数标题 ,是什么意思?
#include <iostream>
using namespace std;
struct person
{ char name[10];unsigned int id;double salary;};
void Input ( person [],const int );
void Sort ( person [],const int );
void Output ( person [],const int );
void main ()
{
person allone[100];
int total;
cout<<"输入员工总数:\n";
cin>>total;
cout<<"输入员工信息:\n";
Input (allone,total);
cout<<"按照工资排序\n";
Sort (allone,total);
cout<<"输出全部信息\n";
Output(allone,total);
}
void Input(person all[],const int n);
{
int i;
for (i=0;i<n;i++)
{
cout<<i<<":姓名:";
cin>>all[i].name;
cout<<"编号";
cin>>all[i].id;
cout<<"工资";
cin>>all[i].salary;
}
}
void Sort(person all[],const int n);
{
int i,j;
double temp;
for (i=1;i<n;i++)
{
for (j=0;j<n-1-i;j++)
if (all[j].salary<all[j+1].salary)
{
temp=all[j].salary;
all[j].salary=all[j+1].salary;
all[j+1].salary=temp;
}
}
}
void Output(person all[],const int n);
{
int i;
for (i=0;i<n;i++)
cout<<all[i].name<<'\t'<<all[i].id<<'\t'<<all[i].salary;
}

[解决办法]

C/C++ code
#include <iostream>using namespace std;typedef struct{ char name[10];unsigned int id;double salary;}person;void Input ( person [],const int );void Sort ( person [],const int );void Output ( person [],const int );int main (){person allone[100];int total;cout<<"输入员工总数:\n";cin>>total;cout<<"输入员工信息:\n";Input (allone,total);cout<<"按照工资排序\n";Sort (allone,total);cout<<"输出全部信息\n";Output(allone,total);return 0;}void Input(person all[],const int n){int i;for (i=0;i<n;i++){cout<<i<<":姓名:";cin>>all[i].name;cout<<"编号";cin>>all[i].id;cout<<"工资";cin>>all[i].salary;}}void Sort(person all[],const int n){int i,j;double temp;for (i=1;i<n;i++){for (j=0;j<n-1-i;j++)if (all[j].salary<all[j+1].salary){temp=all[j].salary;all[j].salary=all[j+1].salary;all[j+1].salary=temp;}}}void Output(person all[],const int n){int i;for (i=0;i<n;i++)cout<<all[i].name<<'\t'<<all[i].id<<'\t'<<all[i].salary;}
[解决办法]
函数实现的时候在函数体后都有分号,例如:
void Sort(person all[],const int n); //这个分号是多的
{
int i,j;
...
}
[解决办法]
去掉函数定义后面的;号后就没有问题了。函数声明时是需要加;好的。定义就不需要哦。

热点排行