spm
unknown
plain_text
a year ago
918 B
1
Indexable
Never
// Online C++ compiler to run C++ program online #include <iostream> #include<string> // void main(){ // int a = 10; //} // Final list contains 'void','main','(','),'}','{','int','a','=','10',';' using namespace std; int main() { string s[100]; string inp; int i=0; while (inp!="0"){ getline(cin,inp); s[i]=inp; i++; } string tokens[100]; int l=i-1; int j=0; string tks1[100] = {"void","main","int","=","-","+","*","/","//","sign","string","char"}; string par[5]={"(",")","{","}",";"}; for (int i=0;i<l;i++){ for (int k=0;k<4;k++){ if (s[i].find(tks1[k])){ tokens[j]=tks1[k]; j++; } } for (int z=0;z<5;z++){ if (s[i].find(par[z])){ tokens[j]=par[z]; j++; } } } cout<<"the tokens are :\n"; for (int i=0;i<10;i++){ cout<<tokens[i]<<endl; } } // void main(){ // int a = 10; // }