Mephistopheles_

lab 3 ТФЯ

Oct 25th, 2021
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. void solution(){
  2.     string s;
  3.     vector<pr<string,string>>v;
  4.     ifstream fl(R"(C:\Users\Slava\Desktop\input1.txt)");
  5.     while(getline(fl,s)){
  6.         forx(i,0,isz(s)){
  7.             string u,t;
  8.             if(isdigit(s[i])){
  9.                 while(isdigit(s[i])|| s[i]=='.'){
  10.                     u+=s[i];
  11.                     ++i;
  12.                 }
  13.                 t="int";
  14.                 --i;
  15.  
  16.             }
  17.             else{
  18.                 if (isalpha(s[i]) || isdigit(s[i]) || s[i]=='.' || s[i]=='/' || s[i]=='_') {
  19.                     while(isalpha(s[i]) || isdigit(s[i]) || s[i]=='.' || s[i]=='/' || s[i]=='_'){
  20.                         u+=s[i];
  21.                         ++i;
  22.                     }
  23.                     --i;
  24.                     t="string";
  25.                 }
  26.                 else if(s[i]!='\n' && s[i]!=' ' && s[i]!='\"'){
  27.                     u+=s[i];
  28.                     t="terminal";
  29.                 }
  30.             }
  31.             if(isz(u)!=0)
  32.                 v.emplace_back(u,t);
  33.         }
  34.     }
  35.     for(auto& [a,b]:v)
  36.         cout<<a+" - "+b+"\n";
  37. }
Advertisement
Add Comment
Please, Sign In to add comment