Advertisement
tarek_ullah

finding_identifiers_of_equations

Mar 2nd, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. /* Author : H. M. Tarek Ullah
  2.    Date : 02.03.15
  3.    About : this program identifies identifiers of any equation
  4. */
  5.  
  6.  
  7. #include<bits/stdc++.h>
  8. using namespace std ;
  9.  
  10. bool isoperator(string s)
  11. {
  12.        for(int i=0 ;i<s.length();i++)
  13.        {
  14.            if(s[i]=='+' || s[i]=='=' || s[i]=='-' || s[i]=='/')
  15.             return true ;
  16.            else if(s[i] >= '0' && s[i]<='9')
  17.                return true ;
  18.            else
  19.             return false ;
  20.        }
  21. }
  22.  
  23. int main()
  24. {
  25.  
  26.  
  27.  string eqn ;
  28.  getline(cin,eqn);
  29.  string r1 ;
  30.  stringstream os(eqn) ;
  31.  vector<string> vec  ;
  32.   while(os>> r1 || !os.eof()){
  33.  
  34.     vec.push_back(r1);
  35.  
  36.   }
  37.   vector<string>::const_iterator it1= vec.begin() ;
  38.   vector<string>::const_iterator it2=vec.end() ;
  39.  
  40.  
  41.   for(vector<string>::const_iterator it=it1;it!=it2;it++)
  42.   {
  43.  
  44.        string s = *it ;
  45.        if(isoperator(s)==false)
  46.         cout << *it << endl;
  47.   }
  48.  
  49.     return 0 ;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement