Advertisement
xxeell

Untitled

Mar 5th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <stdio.h>
  4. #include <fstream>
  5. #include <cctype>
  6. using namespace std;
  7.  
  8. void fun(string s)
  9. {
  10.     cout << "start: " << s << "\n";
  11.     long mas = 0;
  12.     cout << "f_s " << isdigit(s[0]) << "> " << s[0] << " -> ";
  13.     if (isdigit(s[0]))
  14.     {
  15.         mas = int(s[0]) - 48;
  16.         cout << "set " << mas;
  17.     }
  18.     else cout << "none";
  19.     cout << "\n";
  20.  
  21.     bool now, last;
  22.     for (int i = 1; i < s.length(); i++)
  23.     {
  24.         now = isdigit(s[i]);
  25.         last = isdigit(s[i - 1]);
  26.         cout << "0: " << (int)now << " " << (int)last << "> char: " << s[i] << "\n";
  27.  
  28.         if (now && !last)
  29.         {
  30.             mas = int(s[i]) - 48;
  31.             cout << "1> n & !l -> " << mas << "\n";
  32.         }
  33.  
  34.         if (now && last)
  35.         {
  36.             mas = mas * 10 + int(s[i]) - 48;
  37.             cout << "2> n & l -> " << mas << "\n";
  38.         }
  39.  
  40.         if (!now && last)
  41.         {
  42.             cout << "3> !n & l -> " << mas << "\n";
  43.             if (mas % 2 == 0)
  44.                 cout << mas << ' ';
  45.         }
  46.  
  47.         if (now && (i = s.length()-1))
  48.         {
  49.             cout << "4> n & length -> " << mas << "\n";
  50.             if (mas % 2 == 0)
  51.                 cout << mas << ' ';
  52.         }
  53.     }
  54.     cout << endl;
  55. }
  56.  
  57. int main()
  58. {
  59.     string s;
  60.     ifstream in("input.txt");
  61.     while (in.peek() != EOF)
  62.     {
  63.         getline(in, s);
  64.         fun(s);
  65.     }
  66.     in.close();
  67.     //system("pause");
  68.     return 0;
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement