Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <fstream>
- #include <iostream>
- #include <string>
- int main(int argc, char *argv[]) {
- std::ifstream file("text.txt");
- std::string String;
- int amountOfSentence = 0;
- while (getline(file, String)) {
- for (char i : String) {
- if (i == '.' || i == '?' || i == '!') {
- amountOfSentence++;
- }
- }
- }
- std::cout << "Количество предложений: " << amountOfSentence << std::endl;
- file.close();
- file.open("text.txt");
- String = "";
- // 2
- std::string ResultString;
- while (getline(file, String)) {
- for (int i = 0; i < String.length(); i++) {
- switch (String[i]) {
- case '0':
- String.replace(i, 1, "нуль");
- break;
- case '1':
- String.replace(i, 1, "один");
- break;
- case '2':
- String.replace(i, 1, "два");
- break;
- case '3':
- String.replace(i, 1, "три");
- break;
- case '4':
- String.replace(i, 1, "четыре");
- break;
- case '5':
- String.replace(i, 1, "пять");
- break;
- case '6':
- String.replace(i, 1, "шесть");
- break;
- case '7':
- String.replace(i, 1, "семь");
- break;
- case '8':
- String.replace(i, 1, "восемь");
- break;
- case '9':
- String.replace(i, 1, "девять");
- }
- }
- ResultString += String + '\n';
- }
- std::cout << ResultString << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment