Username77177

Dahl-Programming-Lab13-7

May 20th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include <cstdio>
  2. #include <fstream>
  3. #include <iostream>
  4. #include <string>
  5. int main(int argc, char *argv[]) {
  6.   std::ifstream file("text.txt");
  7.   std::string String;
  8.   int amountOfSentence = 0;
  9.   while (getline(file, String)) {
  10.     for (char i : String) {
  11.       if (i == '.' || i == '?' || i == '!') {
  12.         amountOfSentence++;
  13.       }
  14.     }
  15.   }
  16.   std::cout << "Количество предложений: " << amountOfSentence << std::endl;
  17.  
  18.   file.close();
  19.   file.open("text.txt");
  20.   String = "";
  21.  
  22.   // 2
  23.   std::string ResultString;
  24.   while (getline(file, String)) {
  25.     for (int i = 0; i < String.length(); i++) {
  26.       switch (String[i]) {
  27.       case '0':
  28.         String.replace(i, 1, "нуль");
  29.         break;
  30.       case '1':
  31.         String.replace(i, 1, "один");
  32.         break;
  33.       case '2':
  34.         String.replace(i, 1, "два");
  35.         break;
  36.       case '3':
  37.         String.replace(i, 1, "три");
  38.         break;
  39.       case '4':
  40.         String.replace(i, 1, "четыре");
  41.         break;
  42.       case '5':
  43.         String.replace(i, 1, "пять");
  44.         break;
  45.       case '6':
  46.         String.replace(i, 1, "шесть");
  47.         break;
  48.       case '7':
  49.         String.replace(i, 1, "семь");
  50.         break;
  51.       case '8':
  52.         String.replace(i, 1, "восемь");
  53.         break;
  54.       case '9':
  55.         String.replace(i, 1, "девять");
  56.       }
  57.     }
  58.     ResultString += String + '\n';
  59.   }
  60.   std::cout << ResultString << std::endl;
  61.   return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment