Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <stdlib.h>
- #include <string>
- #include <windows.h>
- int counter = 0;
- using namespace std;
- void sentence(string &line);
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- string a;
- string &line = a;
- fstream F;
- string tmp = "1";
- int freq = 1;
- F.open("File.txt");
- while(!F.eof()){
- if(!F.is_open()){
- cout << "not open";
- }else{
- F >> line;
- sentence(line);
- }
- if(tmp.length() < line.length()){
- tmp = line;
- }
- }
- while(!F.eof()){
- if(!F.is_open()){
- cout << "not open";
- }else{
- F >> line;
- if(line == tmp){
- freq++;
- }
- }
- }
- cout << "\n" << tmp << " " << freq << "\n";
- F.close();
- }
- void sentence(string &line){
- bool DOT = false;
- for(int i = 0; i < line.length();i++){
- line[i] != '.' ? counter++ : DOT = true;
- line[i] != '!' ? : DOT = true;
- line[i] != '?' ? : DOT = true;
- if(DOT == true){
- cout << line << "(" << counter << ")" << " ";
- counter = 0;
- }
- }
- if(DOT == false){
- cout << line << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement