Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. //Kamil Roszyk 2b- zadanie maturalne- 5a
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <fstream>
  5. #include <string>
  6. using namespace std;
  7. int main()
  8. {
  9.     int c, d, e, f, g, h, i, j, k, l, m, n;
  10.     c = d = e = f = g = h = i = j = k = l = m = n = 0;
  11.  
  12.     string a;
  13.     ifstream we("slowa.txt");
  14.  
  15.     while (getline(we, a))
  16.     {
  17.         int b = a.size();
  18.         cout << b << "\t";
  19.  
  20.         switch (b){
  21.         case 1:
  22.             c++;
  23.             break;
  24.         case 2:
  25.             d++;
  26.             break;
  27.         case 3:
  28.             e++;
  29.             break;
  30.         case 4:
  31.             f++;
  32.             break;
  33.         case 5:
  34.             g++;
  35.             break;
  36.         case 6:
  37.             h++;
  38.             break;
  39.         case 7:
  40.             i++;
  41.             break;
  42.         case 8:
  43.             j++;
  44.             break;
  45.         case 9:
  46.             k++;
  47.             break;
  48.         case 10:
  49.             l++;
  50.             break;
  51.         case 11:
  52.             m++;
  53.             break;
  54.         case 12:
  55.             n++;
  56.             break;
  57.         }
  58.        
  59.     }
  60.  
  61.     ofstream wy("wynik5a.txt");
  62.     wy << 1 << "\t" << c << endl;
  63.     wy << 2 << "\t" << d << endl;
  64.     wy << 3 << "\t" << e << endl;
  65.     wy << 4 << "\t" << f << endl;
  66.     wy << 5 << "\t" << g << endl;
  67.     wy << 6 << "\t" << h << endl;
  68.     wy << 7 << "\t" << i << endl;
  69.     wy << 8 << "\t" << j << endl;
  70.     wy << 9 << "\t" << k << endl;
  71.     wy << 10 << "\t" << l << endl;
  72.     wy << 11 << "\t" << m << endl;
  73.     wy << 12 << "\t" << n << endl;
  74.  
  75.     wy.close();
  76.     we.close();
  77.  
  78.     return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement