zoukankan      html  css  js  c++  java
  • [Water]Hdu 2054 A == B ?

    This problem is just like java's BigInteger:

    #include <iostream>
    #include <string>
    using namespace std;
    
    string format(string str){
    	bool zheng=true;
    	int ppos=str.find('.');
    	int len=str.length();
    	string s1,s2;
    
    	if(ppos!=-1){
    		int ii;
    		for(ii=len-1;ii>ppos;ii--){
    			if(str[ii]!='0')break;
    		}
    		s2=str.substr(ppos,ii-ppos+1);
    	}
    	else ppos=len;
    
    	int i=0;
    	if(str[i]=='-'){
    		zheng=false;
    		i++;
    	}
    	for(;i<ppos;i++){
    		if(str[i]!='0' ){
    			s1=str.substr(i,ppos-i);
    			break;
    		}
    	}
    	if(s1=="")s1="0";
    	if(s2==".")s2="";
    	if(!zheng)s1="-"+s1;
    	if(s1=="-0" && s2=="")s1="0";
    	//cout<<"s1="<<s1<<"  s2="<<s2<<endl;
    	return s1+s2;
    }
    
    int main(){
    	string a,b;
    	/*while(cin>>a){
    		cout<<format(a)<<endl;
    	}*/
    	while(cin>>a>>b){
    		//cout<<a<<"   "<<b<<endl;
    		a=format(a);
    		b=format(b);
    		//cout<<"   "<<a<<"   "<<b<<"    ";
    		if(a==b)cout<<"YES"<<endl;
    		else cout<<"NO"<<endl;
    	}
    }
    

      

  • 相关阅读:
    学习嵌入式规划
    函数指针与指针函数
    css3
    css
    file upload使用iframe
    上传图片,文件
    table td里面的内容多的话出...
    html5 新标签
    html element
    css/html规范
  • 原文地址:https://www.cnblogs.com/bruce27/p/4548947.html
Copyright © 2011-2022 走看看