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和后面多余的0以及小数点
依旧是 结果错误!!!
最后发现不用考虑数字前面多余的0,出题的bug!!!   只需考虑小数点及其后末尾多余的0
以下为考虑全面的代码
#include<iostream>
#include<string.h>
using namespace std;
char a[2],b[2];
void f(char s[])
{
int n;
n=strlen(s);
while(){
if(s[]==''){
for(int j=;j<n;j++){
s[j]=s[j+];
}
n--;
}
else break;
}
if(strchr(s,'.')){
for(int i=n-;i>=;i--){
if(s[i]==''){
s[i]='\0';
n--;
}
else break;
}
}
if(s[n-]=='.')s[n-]='\0';
}
int main()
{
while(cin>>a>>b){
f(a);
f(b);
if(strcmp(a,b))cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return ;
}

以下为AC代码

#include<iostream>
#include<string.h>
using namespace std;
char a[],b[];
void f(char s[])
{
int n=strlen(s);
if(strchr(s,'.')!=NULL){
for(int i=n-;i>=;i--){
if(s[i]==''){
s[i]='\0';
n--;
}
else break;
}
}
if(s[n-]=='.')s[n-]='\0';
}
int main()
{
while(cin>>a>>b){
f(a);
f(b);
if(strcmp(a,b))cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return ;
}

X - A == B ?(第二季水)的更多相关文章

  1. F - The Fun Number System(第二季水)

    Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight o ...

  2. D - Counterfeit Dollar(第二季水)

    Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are t ...

  3. S - 骨牌铺方格(第二季水)

    Description          在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数.         例如n=3时,为2× 3方格,骨牌的铺放方案有三种, ...

  4. R - 一只小蜜蜂...(第二季水)

    Description          有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行.请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数.         其中,蜂房的结构如下所示.     ...

  5. I - Long Distance Racing(第二季水)

    Description Bessie is training for her next race by running on a path that includes hills so that sh ...

  6. Y - Design T-Shirt(第二季水)

    Description Soon after he decided to design a T-shirt for our Algorithm Board on Free-City BBS, XKA ...

  7. N - Robot Motion(第二季水)

    Description A robot has been programmed to follow the instructions in its path. Instructions for the ...

  8. B - Maya Calendar(第二季水)

    Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old ...

  9. T - 阿牛的EOF牛肉串(第二季水)

    Description          今年的ACM暑期集训队一共有18人,分为6支队伍.其中有一个叫做EOF的队伍,由04级的阿牛.XC以及05级的COY组成.在共同的集训生活中,大家建立了深厚的 ...

  10. E - Number Sequence(第二季水)

    Description A single positive integer i is given. Write a program to find the digit located in the p ...

随机推荐

  1. asp.net缓存(二)

    ASP.NET页面局部缓存 有时缓存整个页面是不现实的,因为页的某些部分可能在每次请求时都需要变化.在这些情况下,只能缓存页的一部分.顾名思义,页面部分缓存是将页面部分内容保存在内存中以便响应用户请求 ...

  2. HttpClient中异步方法的同步调用

    在System.Net.Http中,提供了使用Http与远程服务器通讯的httpClient,但是里面都是异步方法,有时候我们并不需要使用异步操作.这个时候可以使用如下的方式来进行同步调用. clas ...

  3. 安卓tabhost和子Activity通信方法

    发现很多同学在问这个问题 1个tabhost对应的类假设是T,假设包含2个子tab,每个是1个activity,假设叫a,b,对应的类假设是A和B 那么有这几个问题 1.a如何调用b的方法,或者说发送 ...

  4. css3属性:column分栏

    css3选择器中提出了分栏的属性,其浏览器支持情况为:Internet Explorer 10 和 Opera 支持 column 属性,Firefox 支持替代的 -moz-column 属性,Sa ...

  5. Zend Studio 文件头和方法注释设置

    在zend studio中选择窗口->首选项->PHP–>编辑器 –>模板 –>新建 然后添加 funinfo或fileinfo 模板代码根据下边定义的COPY过去就可以 ...

  6. 异常处理与调试6 - 零基础入门学习Delphi55(完)

    调试(Debug) 让编程改变世界 Change the world by program 使用调试窗口 为方便调式程序,Delphi中提供了许多调试窗口,给开发人员的调试工作带来了极大的便利. 断点 ...

  7. [TYVJ] P1030 乳草的入侵

    乳草的入侵 背景 Background USACO OCT09 6TH   描述 Description Farmer John一直努力让他的草地充满鲜美多汁的而又健康的牧草.可惜天不从人愿,他在植物 ...

  8. USB系列之七:ASPI介绍及命令测试

    在以前的一篇博文<关于构建DOS下编程平台的总结>中曾经介绍了一种在DOS下驱动U盘的方法,我们大致回顾一下.在config.sys中加入两个驱动程序,就可以驱动U盘:device = a ...

  9. redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

    超时 Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: jav ...

  10. POJ1094 Sorting It All Out(拓扑排序)

    Sorting It All Out Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 30110   Accepted: 10 ...