include iostream include stdlib include stdio include math include fst

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#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;
}