Advertisement
eitherlast

laba6.cpp

May 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5. #include <ctype.h>
  6.  
  7. using namespace std;
  8.  
  9. bool islatin(char c) {
  10.     if (c > (char)96 && c < (char)123)
  11.         return true;
  12.     else
  13.         return false;
  14. }
  15.  
  16. int main()
  17. {
  18.     setlocale(LC_ALL, "rus");
  19.     string name = "";
  20.     string h;
  21.     char input;
  22.  
  23.     while (cin >> input && input != '=') //EOF - Ctrl + Z
  24.     { //сделать нормальный перевод на новую строчку
  25.     // \n, endl, так далее
  26.         try
  27.         {
  28.             if (!islatin(input) || isdigit(input) || isupper(input))
  29.             {
  30.                 throw 1;
  31.             }
  32.             name += input;
  33.         }
  34.         catch (int i)
  35.         {
  36.             cout << "Введите имя заново. \n";
  37.         }
  38.     }
  39.  
  40.     ofstream fout;
  41.     fout.open(name.c_str());
  42.    
  43.     cout << "Введите хокку. \n";
  44.     cin.get();
  45.     //getline(cin, h);
  46.     cin >> h;
  47.     cout << h;
  48.     fout << h << "\n";
  49.     fout.close();
  50.  
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement