tetst
来源:互联网 发布:linux备份系统 编辑:程序博客网 时间:2024/05/21 17:44
#include <iostream>#include<cstring>using namespace std;int main(){ string str; while(cin>>str){ bool dot = false; bool word = false; int poiDot = 0; int poi = 0; bool vis = false; int ti1 = 0; int ti2 = 0; for(int i = 0;i<str.length();++ i){ if( str[i] =='.' ){ dot = true; poiDot = i; ti1++; } if(str[i]=='E'||str[i]=='e'){ poi = i; word = true; ti2++; } if(str[i]=='+'){ if((i+1)<=str.length()-1){ if(str[i+1]=='+'){ vis = true; } } } if(str[i]=='-'){ if((i+1)<=str.length()-1){ if(str[i+1]=='-'){ vis = true; } } } } if(vis||(ti1>=2)||(ti2>=2) ){ cout<<"NO"<<endl; continue; } if(!dot){ if(word){ if(poi != 0){ int j; bool dot2=false; for(j = poi;j<str.length();++j){ if(str[j] == '.'){ dot2 = true; break; } } if(dot2){ cout<<"NO"<<endl; } if(j==str.length()){ if(poi!=str.length()-1){ cout<<"YES"<<endl; } else cout<<"NO"<<endl; } }else cout<<"NO"<<endl; }else{ cout<<"NO"<<endl; } }else{ if(!word){ if( (poiDot != str.length()-1 )&&(poiDot != 0 ) ){ cout<<"YES"<<endl; }else cout<<"NO"<<endl; }else{ int j; bool dot2 = false; for(j = poi;j<str.length();++j){ if(str[j] == '.'){ dot2 = true; break; } } if(dot2){ cout<<"NO"<<endl; } if(j==str.length()){ if(poi!=str.length()-1){ if( (poiDot+1) != poi ){ cout<<"YES"<<endl; }else cout<<"NO"<<endl; } else cout<<"NO"<<endl; } } } } return 0;}
0 0