Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- struct osoby
- {
- string imie;
- string nazwisko;
- float skutecznosc;
- };
- int main()
- {
- string pliczek;
- cout<<"podaj nazwe pliku"<<endl;
- cin>>pliczek;
- pliczek=pliczek+".txt";
- ifstream plik;
- plik.open(pliczek.c_str());
- if(plik==NULL)
- {
- cout<<"blad otwarcia pliku"<<endl;
- return 0;
- }
- osoby tab[10];
- int i=0;
- while(!plik.eof())//getline(cin, plik)==3)
- {
- plik>>tab[i].imie>>tab[i].nazwisko>>tab[i].skutecznosc;
- i++;
- }
- int k;
- int ilosc=i;
- i=0;
- pliczek.erase( 7, 10 );
- pliczek.append( "max.txt" );
- ofstream klip;
- klip.open(pliczek.c_str());
- int maxi=tab[0].skutecznosc;
- int wynik=0;
- int dlugos;
- for(k=0;k<ilosc;k++)
- {
- if(tab[k].imie.length()>3)
- {
- if(maxi<=tab[k].skutecznosc)
- {
- maxi=tab[k].skutecznosc;
- dlugos=tab[k].nazwisko.length();
- cout<<dlugos<<endl;
- if(tab[k].nazwisko[dlugos-3]=='s' && tab[k].nazwisko[dlugos-2]=='k' && tab[k].nazwisko[dlugos-1]=='i')
- {
- wynik=k;
- }
- }
- }
- }
- klip<<tab[wynik].imie<<tab[wynik].nazwisko<<tab[wynik].skutecznosc;
- klip.close();
- plik.close();
- cout<<endl;
- cout << "Hello world!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement