Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- string pobierz()
- {
- string slowo_szukane;
- cout << "podaj slowo" << endl;
- cin >> slowo_szukane;
- return slowo_szukane;
- }
- int sprawdz(string slowo_szukane)
- {
- ifstream plik;
- plik.open("hamlet.txt");
- string slowo_aktualne;
- int il_slowa = 0;
- while (!plik.eof())
- {
- plik >> slowo_aktualne;
- if(slowo_szukane==slowo_aktualne)
- il_slowa++;
- }
- plik.close();
- return il_slowa;
- }
- int main()
- {
- cout << sprawdz(pobierz()) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment