程序没大问题,就是小错误有点多#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[i].a;
temp.mouth=e[i].mouth;
temp.day=e[i].day;
for(int j=i+1;j<0;j++)
{
if(temp.mouth>e[j].mouth)
{
temp.mouth=e[j].mouth;
temp.day=e[j].day;
temp.a=e[j].a;
}
if(temp.mouth==e[j].mouth)
{
if(temp.day>e[j].day)
{
temp.a=e[j].a;
temp.day=e[j].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[100];
for(int i=0;i<num;i++)
{
cout<<"please input the name of "<<i+1<<" employ "<<endl;
cin>>e_num[i].a;
cout<<"please input the mouth of "<<i+1<<" employ (1-12)"<<endl;
cin>>e_num[i].mouth;
cout<<"please input the day of "<<i+1<<" employ (1-31)"<<endl;
cin>>e_num[i].day;
cout<<endl;
}
sort(e_num,num);
return 0;
}
建议楼主建立良好的代码风格和谨慎的态度 |