HDU 2054 A == B ? 字符串处理
2014-10-31 22:05
357 查看
A == B ?
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 63662 Accepted Submission(s): 9961
Problem Description
Give you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".
Input
each test case contains two numbers A and B.
Output
for each case, if A is equal to B, you should print "YES", or print "NO".
Sample Input
1 2 2 2 3 3 4 3
Sample Output
NO YES YES NO
/* HDU 2054 字符串处理 刚开始没看懂 看了下别人的 这题不好 啥都没说明 有人说有+ -号 但是好像没有 去除前置的的0和小数点后不为零数字后面的0 0000.1 0.1000000 .1 0.1 000.000 0 123456789123456789 123456789123456789 000001000. 1000 */ #include<iostream> #include<stdio.h> #include<string> using namespace std; void change(string &str) { if(strchr(str.c_str(), '.' ) ) { int last=str.length(); while(str[--last]=='0') str.erase(last,1); //删除后置0 if(str[last]=='.') str.erase(last,1) ; //若全为0,删除小数点 } while(str[0]=='0')//前置0的处理 { if(str.length()!=1) str.erase(0,1);//若全为0,则保存一个0 else return; } } int main() { string num1,num2; while(cin>>num1>>num2) { change(num1); change(num2); if(num1.compare(num2)==0) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }
相关文章推荐
- HDU 2054 A == B ? (字符串处理)
- HDU1804——字符串处理
- HDU1894——字符串处理
- HDU 1088 处理每个字符串比直接用getchar处理简单
- 【HDU 3242 List Operations】 字符串处理
- 【HDU 3183】 字符串处理
- HDU 1020 Encoding (字符串处理)
- hdu 2412 (disney) 模拟、字符串处理
- HDU 1014 字符串处理
- HDU——2970(字符串处理)
- hdu 1062 字符串处理
- 【W】HDU2206——字符串处理(IP计算)
- hdu 4054 字符串处理
- hdu 3973 AC's String 字符串哈希处理 查询子串是否是模式串 可以修改
- HDU 1039 字符串处理
- HDU 3819 A and B Problem 对字符串进行处理
- 字符串处理,以HDU 2100为例
- HDU-1039 字符串处理
- HDU 1073 Online Judge (字符串处理,简单题)
- HDU 2206 IP的计算(字符串处理)