Advertisement
Khristina

Задача №6

Apr 22nd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string>
  4. #include <cstring>
  5. #include <math.h>
  6. #include <cstdlib>
  7. #include <fstream>
  8. #include <windows.h>
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     int j, k=1;
  14.     string str = "", str1, str2, str3;
  15.     setlocale(LC_ALL, "Rus");
  16.     ofstream text;
  17.     char arr[15];
  18.     while (k == 1)
  19.     {
  20.         j = 0;
  21.         cout << "Введите имя файла (после ввода названия нажмите * и Enter): " << endl;
  22.         for (int i = 0; i < 15; i++)
  23.         {
  24.             cin >> arr[i];
  25.             if (arr[i] != '*')
  26.             {
  27.                 j++;
  28.             }
  29.             else if (arr[i] == '*')
  30.             {
  31.                 break;
  32.             }
  33.         }
  34.         k = 2;
  35.         for (int i = 0; i < j; i++)
  36.         {
  37.             if (arr[i] >= (char)97 && arr[i] <= (char)122 || arr[i] == (char)46) { }
  38.             else
  39.             {
  40.                 cout << "Имя файла введено некоректно. Введите заново" << endl;
  41.                 k = 1;
  42.                 break;
  43.             }
  44.         }
  45.     }
  46.     for (int i = 0; i < j; i++)
  47.     {
  48.         str += arr[i];
  49.     }
  50.     text.open(str);
  51.     cout << "Введите 1-ю строку:";
  52.     cin >> str1;
  53.     cout << "Введите 2-ю строку:";
  54.     cin >> str2;
  55.     cout << "Введите 3-ю строку:";
  56.     cin >> str3;
  57.     text << str1 << endl << str2 << endl << str3 << endl;
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement