#include <iostream>
#include <fstream>
using namespace std;
int main()
{
//输入
int a[10];
ofstream outfile1("f1.dat"), outfile2("f2.dat");
cout<<"输入5个数"<<endl;
for(int i=0; i<5; i++)
{
cin>>a[i];
outfile1<<a[i]<<" ";
}
cout<<"输入5个数"<<endl;
for(int i=0; i<5; i++)
{
cin>>a[i];
outfile2<<a[i]<<" ";
}
outfile1.close();
outfile2.close();
//放到f2后面
{
ifstream infile("f1.dat");
ofstream outfile("f2.dat",ios::app);
int k;
for(int i=0; i<5; i++)
{
infile >> k;
outfile<<k<<" ";
}
infile.close();
outfile.close();
}
//输出f2
{
int b[10];
ifstream infile("f2.dat");
for(int i=0;i<10;i++)
{
infile >> b[i];
}
infile.close();
for(int i=0;i<10;i++)
{
if(i==9) cout << b[i] << endl;
else cout << b[i] << ' ';
}
}
//排序
{
ifstream infile("f2.dat");
int i,j,t;
for(i=0; i<10; i++)
{
infile>>a[i];
}
for(i=0; i<9; i++)
{
for(j=0; j<9-i; j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
infile.close();
cout<<endl;
ofstream outfile("f3.dat",ios::out);
for( i=0; i<10; i++)
{
outfile<<a[i]<<" ";
cout<<a[i]<<" ";
}
cout<<endl;
outfile.close();
}
return 0;
}