#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <fstream>
#include <string.h>
using namespace std;
struct DATA{
char month[100];
int year;
};
struct shop{
char name[100];
char avtor[100];
DATA data;
float cost;
};
void input (shop &a,ifstream &inf)
{
fgets ( a.name, 100 , FILE * inf);
inf >> a.avtor;
inf >> a.data.month;
inf >> a.data.year;
inf >> a.cost;
}
void out_tt( shop *a)
{
cout<< a->name << '\t' << a->avtor << '\t'<< '\t' <<
a->data.month << '\t' << a->data.year << '\t' << a->cost << endl;
}
void out_tt (shop *a,ofstream &outf)
{
outf << a->name << ' ' << a->avtor << ' ' <<
a->data.month << ' ' << a->data.year << ' ' << a->cost << ' ' << endl;
}
void output_mas ( shop *mas,int n,ofstream &outf)
{
int i;
cout << "*****" << endl;
cout << n << endl;
for (i=0;i<n; i++)
{
out_tt (&mas[i]);
out_tt (&mas[i],outf);
}
}
void sort (shop *a,int n)
{
int i;
bool f=true;
shop temp;
while (f)
{
f=false;
for (i=0;i<n;i++)
{
if (strcmp (a[i].avtor, a[i+1].avtor) > 0)
{
temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
f=true;
}
}
}
}
int main()
{
setlocale (LC_ALL, "Russian");
int n,i;
ifstream inf("input1.txt");
ofstream outf("output1.txt");
shop t[100];
inf >> n;
cout << n << endl;
for (i=0;i<n;i++)
{
input (t[i],inf);
}
outf << "input file \n";
output_mas (t,n,outf);
sort (t,n);
outf << "\ sort file \n";
output_mas(t,n,outf);
shop aaa;
out_tt(&aaa);
return 0;
}