daily pastebin goal
41%
SHARE
TWEET

3 + *

Gologo Mar 23rd, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. #include <stdlib.h>
  5. #include <string>
  6. #include <windows.h>
  7.  
  8. int counter = 0;
  9.  
  10. using namespace std;
  11.  
  12. void sentence(string &line);
  13.  
  14. int main()
  15. {
  16.     SetConsoleCP(1251);
  17.     SetConsoleOutputCP(1251);
  18.  
  19.     string a;
  20.     string &line = a;
  21.     fstream F;
  22.     string tmp = "1";
  23.     int freq = 1;
  24.  
  25.     F.open("File.txt");
  26.  
  27.     while(!F.eof()){
  28.         if(!F.is_open()){
  29.             cout << "not open";
  30.         }else{
  31.             F >> line;
  32.             sentence(line);
  33.         }
  34.         if(tmp.length() < line.length()){
  35.              tmp = line;
  36.         }
  37.     }
  38.  
  39.     while(!F.eof()){
  40.         if(!F.is_open()){
  41.             cout << "not open";
  42.         }else{
  43.             F >> line;
  44.             if(line == tmp){
  45.                 freq++;
  46.             }
  47.          }
  48.     }
  49.  
  50.     cout << "\n" << tmp << " " << freq << "\n";
  51.  
  52.     F.close();
  53. }
  54.  
  55. void sentence(string &line){
  56.     bool DOT = false;
  57.  
  58.     for(int i = 0; i < line.length();i++){
  59.         line[i] != '.' ? counter++ : DOT = true;
  60.         line[i] != '!' ?  : DOT = true;
  61.         line[i] != '?' ?  : DOT = true;
  62.  
  63.          if(DOT == true){
  64.             cout << line << "(" << counter << ")" << " ";
  65.             counter = 0;
  66.          }
  67.     }
  68.  
  69.     if(DOT == false){
  70.         cout << line << " ";
  71.     }
  72. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top