Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <Windows.h>
- using namespace std;
- int main() {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- ifstream fin;
- fin.open("C:/Users/PC/Desktop/file.txt");
- if (!fin.is_open()) {
- cout << "Ошибка открытия файла" << endl;
- }
- else {
- int size = 0;
- string word, longest_word;
- while (!fin.eof()) {
- fin >> word;
- if (word.size() > size) {
- longest_word = word;
- size = word.size();
- }
- }
- fin.close();
- cout << longest_word << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement