Advertisement
huutho_96

Fixed

Mar 8th, 2017
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.96 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<vector>
  4. #include<string>
  5.  
  6. using namespace std;
  7. void doc(){
  8.     string str;
  9.     ifstream file;
  10.     file.open("text1.txt");
  11.     while (!file.eof())
  12.     {
  13.         getline(file, str);
  14.         cout << str << endl;
  15.     }
  16.     file.close();
  17. }
  18. void ghi(){
  19.     string s;
  20.     ofstream file;
  21.     file.open("text1.txt", ios::app);
  22.     cout << "nhap chuoi:" << endl;
  23.     getline(cin, s);
  24.     file << s << endl;
  25.     file.close();
  26. }
  27. string chuanHoaChu(string &a){
  28.     int l = a.size();
  29.     string b;
  30.     int j = 0;
  31.     //xoa dau cách
  32.     for (int i = 0; i < l; i++){
  33.         if (a[i] == ' '){
  34.             if (i != 0 && a[i - 1] != ' ')
  35.                 b += a[i];
  36.         }
  37.         else
  38.             b += a[i];
  39.     }
  40.  
  41.     int m;
  42.     // chu in hoa va chu thuong
  43.     for (m = 0; m < l; m++){
  44.         if (b[m] != ' '){
  45.             if (m == 0 || b[m - 1] == ' '){
  46.                 if (b[m] >= 97)
  47.                     b[m] -= 32;
  48.             }
  49.             else
  50.             if (b[m] < 97)
  51.                 b[m] += 32;
  52.         }
  53.     }
  54.  
  55.     return b;
  56. }
  57. void chinhSua(){
  58.     fstream file("text1.txt");
  59.     string line;
  60.     while (getline(file, line))
  61.     {
  62.         line = chuanHoaChu(line);
  63.         cout << line << endl;
  64.     }
  65. }
  66. int soCau(ifstream  in){
  67.  
  68.     in.open("text1.txt");
  69.     int count = 0;
  70.     char c;
  71.     while (!in.eof())
  72.     {
  73.         in >> c;
  74.         if (c == '.' || c == '!' || c == '?')
  75.             count++;
  76.     }
  77.     cout << count;
  78.     in.close();
  79.     return c;
  80. }
  81. int  soTu(){
  82.     chinhSua();
  83.     ifstream file;
  84.     ofstream file1;
  85.     file.open("text1.txt");
  86.     int count = 0;
  87.     string s;
  88.     while (!file.eof()){
  89.         file >> s;
  90.         count++;
  91.     }
  92.     file.close();
  93.     file1.close();
  94.     cout << count << endl;
  95.     return count;
  96. }
  97. string alphabet(string a){
  98.     string *p;
  99.     string b;
  100.     p = new string;
  101.     //tach tung tu cua string
  102.     int j = 0;
  103.     int dem = 0;
  104.     for (int i = 0; i < a.size(); i++){
  105.         while (a[i] != ' ')
  106.         {
  107.             p[i][j++] = a[i];
  108.             dem++;
  109.         }
  110.         j = 0;
  111.     }
  112.     //so sánh alphabet
  113.     for (int i = 0; i <dem; i++){
  114.         if (p[i].compare(p[i + 1]) > 0){
  115.             swap(p[i], p[i + 1]);
  116.         }
  117.     }
  118.     cout << dem << endl;
  119.     delete[]p;
  120.     return *p;
  121. }
  122. int main(){
  123.  
  124.  
  125.     soTu();
  126.     system("pause");
  127.     return 0;
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement