Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Kamil Roszyk 2b
- //zadanie maturalne- 5a
- //Dla każdej liczby naturalnej n z przedziału <1, 12> wyznacz liczbę wierszy w pliku
- //slowa.txt, zawierających słowa n-literowe. Wypisz w osobnych wierszach pary: liczba
- //n oraz liczba wierszy z n-literowymi słowami.
- #include <iostream>
- #include <cstdlib>
- #include <fstream>
- #include <string>
- using namespace std;
- int main()
- {
- int T[12]={0,0,0,0,0,0,0,0,0,0,0},i;
- string a;
- ifstream we("slowa.txt");
- while (getline(we, a))
- {
- int b = a.size();
- for(i=0;i<12;i++)
- {
- if(i+1==b)
- {
- T[i]++;
- }
- }
- }
- ofstream wy("wynik5a.txt");
- for(i=0;i<12;i++)
- {
- wy << i+1 << "\t" << T[i] << endl;
- }
- wy.close();
- we.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement