Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <vector>
- using namespace std;
- void wczytaj(vector<int> &data, char x)
- {
- fstream plik("dane.txt");
- if (plik.is_open())
- {
- while (!plik.eof())
- {
- string line;
- getline(plik, line);
- int a = 0;
- for (int i = 0; i < line.size(); i++)
- {
- char znak = line.at(i);
- if (znak == x)
- a++;
- }
- data.push_back(a);
- }
- }
- }
- void wypisz(vector<int> tab, char x)
- {
- cout << "W pliku dane.txt znak " << x << " wystapil: " << endl;
- for (int i = 0; i < tab.size(); i++)
- {
- cout << "Wiersz nr " << i + 1 << " : " << tab.at(i) << endl;
- }
- }
- void czytajZnak(char& x)
- {
- cout << "Podaj znak do szukania: ";
- x = getchar();
- cout << endl << endl;
- }
- int main()
- {
- vector<int> tab;
- char x;
- czytajZnak(x);
- wczytaj(tab,x);
- wypisz(tab, x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement