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. CoutDownLatch 多线程同步辅助类

    CountDownLatch,一个同步辅助类,在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待. 主要方法 public CountDownLatch(int count); pu ...

  2. OD调试1--第一个win32程序

    OD调试一:第一个Win32程序的修改 在软件开发的过程中,程序员会使用一些调试工具,以便高效地找出软件中存在的错误.而在逆向分析领域,分析者也会利用相关的调试工具来分析软件的行为并验证分析结果.由于 ...

  3. Jquery表单与表格的运用

    1,表单的应用: a. 单行文本框的应用  多行文本框的应用 b.复选框的框的应用 c.下拉框的应用 d.表单验证 2,表格的应用: a. 表格变色 b.表格展开关闭 d.表格内容筛选 3,多行文本框 ...

  4. 秒(s) 毫秒(ms) 微秒(μs) 纳秒(ns) 皮秒(ps)及Java获得 .

    Date date=new Date(); long hm=date.getTime(); //获取毫秒 或者 毫秒级:System.currentTimeMillis() 纳秒级: System.n ...

  5. tp中u方法的使用

    自学的时候都没怎么使用过该方法,现在刚进入一个新公司参加项目.发现这个方法用的很多,所以记录下来防止以后忘了. U方法用于完成对URL地址的组装,特点在于可以自动根据当前的URL模式和设置生成对应的U ...

  6. 异常处理与调试4 - 零基础入门学习Delphi53

    调试(Debug) 让编程改变世界 Change the world by program 调试(Debug) 在应用程序开发中检测.处理程序中的错误是一个非常重要的环节.在Delphi的集成开发环境 ...

  7. WPF安装部署小结

    开机启动 右击"MySetup">>"视图">>"注册表",在"HKEY_LOCAL-MACHINE&qu ...

  8. 一次oracle大量数据删除经历

    oracle有个数据表现在已经有2500万条数据了,软件用到这个表的数据时就变的特别慢,所以准备把一个月以前的数据全部清除. 我的步骤是(下边操作都是在plsql中运行的) 1.首先 将这个月的数据导 ...

  9. SQL Server 2008空间数据应用系列六:基于SQLCRL的空间数据可编程性

    原文:SQL Server 2008空间数据应用系列六:基于SQLCRL的空间数据可编程性 友情提示,您阅读本篇博文的先决条件如下: 1.本文示例基于Microsoft SQL Server 2008 ...

  10. Linux用户与用户组,UID及GID

    以下列出文章: Linux系统下如果查看用户的UID和GID:http://blog.csdn.net/ahangliu/article/details/7567444 Linux的用户和用户组管理: ...