Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. struct osoby
  7. {
  8. string imie;
  9. string nazwisko;
  10. float skutecznosc;
  11. };
  12.  
  13. int main()
  14. {
  15. string pliczek;
  16. cout<<"podaj nazwe pliku"<<endl;
  17. cin>>pliczek;
  18. pliczek=pliczek+".txt";
  19.  
  20. ifstream plik;
  21. plik.open(pliczek.c_str());
  22. if(plik==NULL)
  23. {
  24. cout<<"blad otwarcia pliku"<<endl;
  25. return 0;
  26. }
  27. osoby tab[10];
  28. int i=0;
  29. while(!plik.eof())//getline(cin, plik)==3)
  30. {
  31. plik>>tab[i].imie>>tab[i].nazwisko>>tab[i].skutecznosc;
  32. i++;
  33. }
  34. int k;
  35. int ilosc=i;
  36. i=0;
  37. pliczek.erase( 7, 10 );
  38. pliczek.append( "max.txt" );
  39. ofstream klip;
  40. klip.open(pliczek.c_str());
  41. int maxi=tab[0].skutecznosc;
  42. int wynik=0;
  43. int dlugos;
  44. for(k=0;k<ilosc;k++)
  45. {
  46. if(tab[k].imie.length()>3)
  47. {
  48. if(maxi<=tab[k].skutecznosc)
  49. {
  50. maxi=tab[k].skutecznosc;
  51. dlugos=tab[k].nazwisko.length();
  52. cout<<dlugos<<endl;
  53. if(tab[k].nazwisko[dlugos-3]=='s' && tab[k].nazwisko[dlugos-2]=='k' && tab[k].nazwisko[dlugos-1]=='i')
  54. {
  55. wynik=k;
  56. }
  57. }
  58. }
  59. }
  60. klip<<tab[wynik].imie<<tab[wynik].nazwisko<<tab[wynik].skutecznosc;
  61. klip.close();
  62. plik.close();
  63.  
  64. cout<<endl;
  65. cout << "Hello world!" << endl;
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement