Guest User

Untitled

a guest
Nov 3rd, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <conio.h>
  4. #include <iomanip>
  5. #define N 128
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     ifstream file1("text.txt");
  12.     char A, W[N];
  13.     int a=0, b=0;
  14.     double r;
  15.  
  16.     while(! file1.eof())
  17.     {
  18.         A=file1.get();
  19.         if((A>=65 && A<=90) || (A>=97 && A<=122) || (A>=128 && A<=175) || (A>=224 && A<=247)) a++;
  20.     }
  21.     file1.close();
  22.     ifstream file2("text.txt");
  23.  
  24.     while(! file2.eof())
  25.     {
  26.         file2 >> W;
  27.         cout << W << ' ';
  28.         b++;
  29.     }
  30.     file2.close();
  31.  
  32.     cout << "\nSymvol: " << a;
  33.     cout << "\nSlov: " << b;
  34.  
  35.     r=a/b;
  36.     cout << fixed << setprecision(7) << "\nSerednya kil'kist' symvolov na slovo: " << r;
  37.     getch();
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment