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. MagicalRecord(简化CoreData操作)

    1.新建项目不勾选coredata 2.pod 'MagicalRecord' 3.新建模型文件 4.添加实体和属性 5.Create NSManagedObject subclass 6.增 Per ...

  2. 安装SQL2008时遇到"未能加载文件或"file:///d:microsoft..sql.chainer.packagedata.dll"或它的某个依赖项

    安装SQL2008时遇到"未能加载文件或"file:///d:microsoft..sql.chainer.packagedata.dll"或它的某个依赖项,如下图所示 ...

  3. 面试题:Java静态/非静态方法重写

    1.非静态方法重写 public class Test { public static void main(String[] args) throws Exception { Tree pine = ...

  4. (原)配置vs2013使用intel的IPP库

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5473890.html 参考网址: https://software.intel.com/en-us/n ...

  5. jquery file upload 后台收到的文件名中文乱码, filename中文乱码

    在jQuery File Upload.js文件里,在以下这个js中有个成员叫做 _initXHRData, 是一个function, 在这个function的最后部分有一个if-else分支,如下:

  6. Lucene学习总结之四:Lucene索引过程分析

    对于Lucene的索引过程,除了将词(Term)写入倒排表并最终写入Lucene的索引文件外,还包括分词(Analyzer)和合并段(merge segments)的过程,本次不包括这两部分,将在以后 ...

  7. python-整理-logging日志

    python的日志功能模块是logging 功能和使用方式非常类似于log4 如何使用logging: # 导入日志模块import logging# 使用配置文件设置日志时,需要导入这个模块 imp ...

  8. Eloquent ORM 学习笔记

    最近在学习Laravel,觉得ORM功能很强大,我这里只是简单探索了一点,如果有更好的笔记,还请分享. 因为重点在于Eloquent ORM,所以路由设置,控制器就不详细描述了,这里直接进入Model ...

  9. 安装好ubuntu之后要干的几件事

    安装完ubuntu之后啊,系统除了自带了firefox,libre office等能用,要应付日常需求还差了些.然后我根据最近我的需求写了个清单.完成这个清单就让ubuntu成了一个得心应手的好工具了 ...

  10. Slack 开源替代品 Rocket.Chat(聊天,文件上传等等)

    Rocket.Chat 是特性最丰富的 Slack 开源替代品之一. 主要功能:群组聊天,直接通信,私聊群,桌面通知,媒体嵌入,链接预览,文件上传,语音/视频 聊天,截图等等. Rocket.Chat ...