Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////email checker//////////////////////
- /*in the name of Allah */
- # include <list>
- # include <deque>
- # include <bitset>
- # include <algorithm>
- # include <functional>
- # include <numeric>
- # include <utility>
- # include <sstream>
- # include <iostream>
- # include <iomanip>
- # include <cstdio>
- # include <cmath>
- # include <cstdlib>
- # include <ctime>
- # include <set>
- # include <map>
- # include <cmath>
- # include <queue>
- # include <limits>
- # include <stack>
- # include <vector>
- # include <cstring>
- # include <cstdio>
- using namespace std;
- # define all(c) (c).begin(), (c).end()
- template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();}
- int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}
- int main()
- {
- int ca=0;
- string s;
- while(cin>>s){
- string t="";
- int bo=0;
- if(s[0]>='0' && s[0]<='9')bo=0;else bo=1;
- for(int i=0;i<s.size();i++)t+=(char)tolower(s[i]);
- reverse(all(t));
- int at=0;
- if(bo==1)if(t.substr(0,4)=="moc.")
- {
- bo=1;
- }else bo=0;
- int pos=-1;
- if(bo==1)
- {
- for(int i=4;i<t.size();++i)
- {
- if(t[i]=='@'){at=1;break;}
- pos=i;
- if((t[i]>='a' && t[i]<='z') || t[i]=='.')
- bo=1;
- else bo=0;
- if(t[i]=='.' && (t[i+1]=='.' || t[i-1]=='.'||t[i+1]=='@'))bo=0;
- if(bo==0)break;}
- }
- if(bo==1)
- {
- for(int i=pos+2;i<t.size();i++)
- {if((t[i]>='a'&& t[i]<='z')||(t[i]>='0' && t[i]<='9'))bo=1;
- else bo=0;
- if(bo==0)break;}
- }
- if(bo==1 && pos>=4 && at==1)cout<<"Valid Email"<<endl;else cout<<"Invalid Email"<<endl;
- }
- return 0;
- }
- /////////////////////////////////////////////////////////////////
- //////////////////Expression Identifier/////////////////////////
- /*in the name of Allah */
- # include <list>
- # include <deque>
- # include <bitset>
- # include <algorithm>
- # include <functional>
- # include <numeric>
- # include <utility>
- # include <sstream>
- # include <iostream>
- # include <iomanip>
- # include <cstdio>
- # include <cmath>
- # include <cstdlib>
- # include <ctime>
- # include <set>
- # include <map>
- # include <cmath>
- # include <queue>
- # include <limits>
- # include <stack>
- # include <vector>
- # include <cstring>
- # include <cstdio>
- using namespace std;
- # define all(c) (c).begin(), (c).end()
- template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();}
- int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}
- bool chk(string s,string sit)
- {
- if(sit=="flt")
- {
- int f=0;
- for(int i=0;i<s.size();i++)
- {
- if(s[i]=='.')f++;
- if(s[i]=='.')if(s[i+1]=='.' || s[i-1]=='.')return false;
- if((char)tolower(s[i])>='a' && (char)tolower(s[i])<='z')return false;
- }
- if(f>1)return false;
- }
- if(sit=="sci")
- {
- int f=0,ss=0;
- for(int i=0;i<s.size();i++)
- {
- if(s[i]=='.')f++;
- if(s[i]=='E')ss++;
- if(s[i]=='.')if(s[i+1]=='E')return false;
- if(s[i]=='.')if(s[i+1]=='.')return false;
- if(s[i]=='E')if(s[i+1]=='.')return false;
- if(s[i]=='E')if(s[i+1]=='E')return false;
- }
- if(f>1 || ss>1 || ss==0)return false;
- }
- return true;
- }
- bool cmp(string s, string t)
- {
- if(s.size()<t.size())return true;
- else if(s<t)return true;
- return false;
- }
- int main()
- {
- int ca=0;
- string s;
- while(1){
- vector<string>ni;
- getline(cin,s);
- stringstream t(s);
- while(t>>s)
- {
- ni.push_back(s);
- }
- int sci=0,in=0,flt=0,ide=0,inv=0,ope=0;
- vector<string>integer,floating,identifier,operators,scientific,invalid;
- for(int i=0;i<ni.size();i++)
- {
- sci=0,in=0,flt=0,ide=0,inv=0,ope=0;
- if(ni[i][0]=='+'|| ni[i][0]=='-'||ni[i][0]=='*'||ni[i][0]=='/' || ni[i][0]=='=')ope=1;
- else if(ni[i][0]>='0' && ni[i][0]<='9')
- {
- for(int j=1;j<ni[i].size();j++)
- {
- if(ni[i][j]>='a' && ni[i][j]<='z'){inv=1;goto a;}
- else if((ni[i][j]=='.' && (ni[i][j-1]!='E' || ni[i][j+1]!='E')) && (ni[i][j]=='E' && ni[i][j-1]!='.') && ni[i][j]=='E'){if(chk(ni[i],"sci"))sci=1;else if(chk(ni[i],"sci"))flt=1; else inv=1;goto a;}
- else if(ni[i][j]=='.' && ni[i][j]!='E'){if(chk(ni[i],"flt")){flt=1;}else if(chk(ni[i],"sci"))sci=1; else inv=1; goto a;}
- else if(ni[i][j]!='.' && ni[i][j]=='E'){if(chk(ni[i],"sci"))sci=1;else inv=1;goto a;}
- }
- in=1;
- }
- else if( (ni[i][0]>='a' && ni[i][0]<='z') || (ni[i][0]>='A' && ni[i][0]<='Z') || ni[i][0]=='_') ide=1;
- else inv=1;
- //cout<<ni[i]<<" "<<sci<<" "<<in<<" "<<inv<<" "<<ope<<" "<<ide<<" "<<flt<<endl;
- a:
- if(sci==1)scientific.push_back(ni[i]);
- if(sci!=1 || inv!=1 || flt!=1) if(in==1)integer.push_back(ni[i]);
- if(inv==1)invalid.push_back(ni[i]);
- if(ope==1)operators.push_back(ni[i]);
- if(ide==1)identifier.push_back(ni[i]);
- if(sci!=1 && flt==1)floating.push_back(ni[i]);
- }
- if(ni.size()>=1){
- identifier.erase(unique(all(identifier)),identifier.end());
- sort(all(identifier),cmp);
- cout<<"Identifires are: ";
- for(int i=0;i<identifier.size();i++)cout<<identifier[i]<<" ";
- cout<<endl;
- integer.erase(unique(all(integer)),integer.end());
- sort(all(integer),cmp);
- cout<<"Integers are: ";
- for(int i=0;i<integer.size();i++)cout<<integer[i]<<" ";
- cout<<endl;
- floating.erase(unique(all(floating)),floating.end());
- sort(all(floating),cmp);
- cout<<"floatings are: ";
- for(int i=0;i<floating.size();i++)cout<<floating[i]<<" ";
- cout<<endl;
- scientific.erase(unique(all(scientific)),scientific.end());
- sort(all(scientific),cmp);
- cout<<"Scientific numbers are: ";
- for(int i=0;i<scientific.size();i++)cout<<scientific[i]<<" ";
- cout<<endl;
- operators.erase(unique(all(operators)),operators.end());
- sort(all(operators),cmp);
- cout<<"Operators are: ";
- for(int i=0;i<operators.size();i++)cout<<operators[i]<<" ";
- cout<<endl;
- invalid.erase(unique(all(invalid)),invalid.end());
- sort(all(invalid),cmp);
- cout<<"Invalids are: ";
- for(int i=0;i<invalid.size();i++)cout<<invalid[i]<<" ";
- cout<<endl;
- }
- else
- cout<<endl<<endl;
- }
- return 0;
- }
- ////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement