Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <fstream>
- #include <iostream>//
- using namespace std;//
- int main()
- {
- ifstream f1("Text.txt");//отсюда читаем
- /*
- ifstream f1; //то же самое, что и наверху
- f1.open("Text.txt");
- */
- ofstream f2("Text1.txt");//сюда записываем количество слов
- ofstream f3("Text2.txt");//записываем сам текст
- char x, pre;
- int count=0;
- if (f1.get(x))//для первого символа
- {
- f3 << x;
- if (x != ' ')
- count++;
- pre = x;
- }
- while (f1.get(x))//пока файл не кончился считываем один символ
- {
- f3 << x;//записываем в 3 файл
- if (pre == ' '&&x != ' ')
- count++;
- pre = x;
- }
- f2 << count;
- f1.close();
- f2.close();
- f3.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment