HDOJ-2054
2024-09-18 09:00:14
A == B ?
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 88211 Accepted Submission(s): 13922Problem DescriptionGive you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".Inputeach test case contains two numbers A and B.Outputfor each case, if A is equal to B, you should print "YES", or print "NO".Sample Input1 2
2 2
3 3
4 3Sample OutputNO
YES
YES
NO
本以为是一道水题,没想到处处坑点,被坑了一发。。
数组尽量开大一点,注意小数后无意义的0
AC代码:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; const int MAX=;
char a[MAX]={},b[MAX]={}; int main(){ while(scanf("%s %s",&a,&b)!=EOF){
int i=;
if(strchr(a,'.')){//a中是否含小数点
for(i=strlen(a)-;a[i]=='';i--)
a[i]='\0';//消掉末尾的0
if(a[i]='.')
a[i]='\0';//消掉无意义的小数点
}
if(strchr(b,'.')){
for(i=strlen(b)-;b[i]=='';i--)
b[i]='\0';
if(b[i]='.')
b[i]='\0';
}
printf(strcmp(a,b)?"NO\n":"YES\n");//strcmp函数当a,b相等时返回值为0
}
return ;
}
最新文章
- Codeforces 696 C. PLEASE
- 在ASP.NET MVC中使用Unity进行依赖注入的三种方式
- memcached缓存失效时的高并发访问问题解决
- diamond operator is not supported in -source 1.5
- Datawindow.net 子数据窗口出错
- *[topcoder]LongWordsDiv2
- The required Server component failed to start so Tomcat is unable to start解决之一
- Spring Boot集成Jasypt安全框架
- Codeforces Round #346 (Div. 2) D Bicycle Race
- thinkPHP替换SQL变量
- JavaWeb中jdbcproperties配置文件
- SpringMVC 注解式开发
- 山西某公司NetApp存储不小心删除文件数据恢复成功案例
- JavaScript问题——在浏览器中每一个元素都有一个offsetParent属性,这个属性是什么?
- pip常用命令、配置pip源
- hdu1506单调栈的宽度
- [No000010D]Git6/9-分支管理
- Node 内存控制
- SQL Server无法打开物理文件,操作系统错误 5:";5(拒绝访问。)的解决办法
- CSS快速入门-定位布局(九宫格)