Advertisement
Guest User

Untitled

a guest
May 24th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. //Kamil Roszyk 2b
  2. //zadanie maturalne- 5a
  3. //Dla każdej liczby naturalnej n z przedziału <1, 12> wyznacz liczbę wierszy w pliku
  4. //slowa.txt, zawierających słowa n-literowe. Wypisz w osobnych wierszach pary: liczba
  5. //n oraz liczba wierszy z n-literowymi słowami.
  6. #include <iostream>
  7. #include <cstdlib>
  8. #include <fstream>
  9. #include <string>
  10. using namespace std;
  11. int main()
  12. {
  13.         int T[12]={0,0,0,0,0,0,0,0,0,0,0},i;
  14.        
  15.  
  16.         string a;
  17.         ifstream we("slowa.txt");
  18.  
  19.         while (getline(we, a))
  20.         {
  21.                 int b = a.size();
  22.                 for(i=0;i<12;i++)
  23.                 {                            
  24.                  if(i+1==b)
  25.                 {
  26.                         T[i]++;
  27.                
  28.                 }
  29.                
  30.                 }
  31.         }
  32.  
  33.        
  34.         ofstream wy("wynik5a.txt");
  35.        
  36.        
  37.         for(i=0;i<12;i++)
  38.         {
  39.         wy << i+1 << "\t" << T[i] << endl;
  40.         }
  41.        
  42.         wy.close();
  43.         we.close();
  44.  
  45.         return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement