Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <cstring>
- #include <ctime>
- #include <fstream>
- using namespace std;
- struct magazin
- {
- char ime[50];
- int brstoki;
- double oborot;
- };
- magazin mas[100];
- int n;
- void filll()
- {
- cin>>n;
- for(int i=0;i<n;i++)
- {cin.ignore();
- cin.getline(mas[i].ime,50);
- cin>>mas[i].brstoki;
- cin>>mas[i].oborot;}
- }
- void writefile(char *pathfile)
- {
- ofstream f(pathfile,ios::in);
- for(int i=0;i<n;i++)
- {f<<mas[i].ime<<endl;
- f<<mas[i].brstoki<<endl;
- f<<mas[i].oborot<<endl;}
- f.close();
- }
- void show()
- {
- for(int i=0;i<n;i++)
- cout<<mas[i].ime<<' '<<mas[i].brstoki<<' '<<mas[i].oborot<<' ';
- }
- void indmax(char *pathfile1)
- {
- ofstream f1(pathfile1,ios::app);
- double m=mas[0].oborot;
- for(int i=0;i<n;i++)
- if(m<mas[i].oborot)
- m=mas[i].oborot;
- f1<<m<<endl;;
- f1.close();
- }
- void averge(char *pathfile1)
- {
- double br=0.0;
- double q;
- ofstream f1(pathfile1,ios::app);
- for(int i=0;i<n;i++)
- br=br+mas[i].oborot;
- q=br/double(n);
- f1<<q;
- f1.close();
- }
- void readfile(char *pathfile2)
- {
- ifstream f2(pathfile2,ios::in);
- }
- int main()
- {
- char pathfile[200]="D:\\Jelqzkova\\Georgi 9a\\readf.txt";
- char pathfile1[200]="D:\\Jelqzkova\\Georgi 9a\\readf1.txt";
- char pathfile2[200]="D:\\Jelqzkova\\Georgi 9a\\readf2.txt";
- filll();
- writefile(pathfile);
- show();
- indmax(pathfile1);
- averge(pathfile1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement