程序没法运行不知道怎么回事,求解答
将员工信息按照职工号大小排序再在输出到磁盘文件中保存。
#include<iostream>
#include<fstream>
using namespace std;
struct employee
{
int num;//职工号
string name;//姓名
int age;//年龄
int mon;//工资
};
int main()
{
struct employee temp;
struct employee emp[5] =
{
{002,"wang",56,3000},
{001,"li",34,4000},
{004,"zhu",23,5000},
{003,"bao",24,6000},
{050,"chao",19,3000}
};//输入信息
for (int i = 0; i <= 4; i++)
{
for (int j = 0; j <= 4 - i; j++)
{
if (emp[j].num >emp[j + 1].num)
{
emp[j] = temp;
emp[j] = emp[j + 1];
emp[j + 1] = temp;
}
}
}
//冒泡排序
ofstream infile("职工表");
for (int i = 0; i <= 4; i++)
{
infile << emp[i].num;
infile << emp[i].name;
infile << emp[i].age;
infile << emp[i].mon;
}
infile.close();
return 0;
}