C++ 错误-error: functional cast expression list treated as compound expression
本帖最后由 小水 于 2014-4-29 20:58 编辑编译出现错误,求大神讲解error: functional cast expression list treated as compound expression
函数实现功能:输入员工的姓名,出生日期(月/日),按日期大小输出员工姓名
代码:
#include<iostream>
using namespace std;
struct Employ{
string a;
int mouth;
int day;
};
void sort(Employ e[],int n)
{
Employ temp;
for(int i=0;i<n;i++)
{ temp.a=e.a;
temp.mouth=e.mouth;
temp.day=e.day;
for(int j=i+1;j<0;j++)
{
if(temp.mouth>e.mouth)
{temp.mouth=e.mouth;
temp.day=e.day;
temp.a=e.a;
}
if(temp.mouth==e.mouth){
if(temp.day>e.day)
{
temp.a=e.a;
temp.day=e.day;
}
}
}
cout<<temp.a<<temp.mouth<<temp.day<<endl;
}
}
int main()
{
int num;
cout<<"please intput the number of employ"<<endl;
cin>>num;
Employ e_num;
for(int i=0;i<num;i++)
{
cout<<"please input the name of "<<i+1<<"employ "<<endl;
cin>>e_num.a;
cout<<"please input the mouth of "<<i+1<<"employ (1-12)"<<endl;
cin>>e_num.mouth;
cout<<"please input the day of "<<i+1<<"employ (1-31)"<<endl;
cin>>e_num.day;
cout<<endl;
}
void(e_num,num);
return 0;
}
程序没大问题,就是小错误有点多#include <iostream>
#include <string>
using namespace std;
struct Employ
{
string a;
int mouth;
int day;
};
void sort(Employ e[],int n)
{
Employ temp;
for(int i=0;i<n;i++)
{
temp.a=e.a;
temp.mouth=e.mouth;
temp.day=e.day;
for(int j=i+1;j<0;j++)
{
if(temp.mouth>e.mouth)
{
temp.mouth=e.mouth;
temp.day=e.day;
temp.a=e.a;
}
if(temp.mouth==e.mouth)
{
if(temp.day>e.day)
{
temp.a=e.a;
temp.day=e.day;
}
}
}
cout<<temp.a<<' '<<temp.mouth<<' '<<temp.day<<endl;
}
}
int main()
{
int num;
cout<<"please intput the number of employ"<<endl;
cin>>num;
cout<<endl;
Employ e_num;
for(int i=0;i<num;i++)
{
cout<<"please input the name of "<<i+1<<"employ "<<endl;
cin>>e_num.a;
cout<<"please input the mouth of "<<i+1<<"employ (1-12)"<<endl;
cin>>e_num.mouth;
cout<<"please input the day of "<<i+1<<"employ (1-31)"<<endl;
cin>>e_num.day;
cout<<endl;
}
sort(e_num,num);
return 0;
}建议楼主建立良好的代码风格和谨慎的态度
页:
[1]