A == B ?

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 88211    Accepted Submission(s): 13922

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
 

本以为是一道水题,没想到处处坑点,被坑了一发。。

数组尽量开大一点,注意小数后无意义的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 ;
}

最新文章

  1. Codeforces 696 C. PLEASE
  2. 在ASP.NET MVC中使用Unity进行依赖注入的三种方式
  3. memcached缓存失效时的高并发访问问题解决
  4. diamond operator is not supported in -source 1.5
  5. Datawindow.net 子数据窗口出错
  6. *[topcoder]LongWordsDiv2
  7. The required Server component failed to start so Tomcat is unable to start解决之一
  8. Spring Boot集成Jasypt安全框架
  9. Codeforces Round #346 (Div. 2) D Bicycle Race
  10. thinkPHP替换SQL变量
  11. JavaWeb中jdbcproperties配置文件
  12. SpringMVC 注解式开发
  13. 山西某公司NetApp存储不小心删除文件数据恢复成功案例
  14. JavaScript问题——在浏览器中每一个元素都有一个offsetParent属性,这个属性是什么?
  15. pip常用命令、配置pip源
  16. hdu1506单调栈的宽度
  17. [No000010D]Git6/9-分支管理
  18. Node 内存控制
  19. SQL Server无法打开物理文件,操作系统错误 5:&quot;5(拒绝访问。)的解决办法
  20. CSS快速入门-定位布局(九宫格)

热门文章

  1. PHP读取远程文件的4种方法
  2. Hive merge(小文件合并)
  3. ssh 保持连接
  4. java 的PO、VO、TO、BO、DAO、POJO解释(转载)
  5. Android活动条(actionbar)使用具体解释(一)
  6. JQuery 如何获取select选中的值
  7. 用ASTERISK搭建自己的免费VOIP服务器
  8. const位置上的不同代表哪些不同的意义
  9. LightOJ1370 Bi-shoe and Phi-shoe —— 欧拉函数
  10. SpringMVC与Struts2区别与比较