A == B ?

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

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
 
Author
8600 && xhd
 
Source
 

此题解法:分整数和小数两部分来比较即可!!但要注意的事情还是比较多的

需要考虑:

+0.000    0.00

YES

+0.00 -0.00

YES

+0001.00 1

YES

+000.0000100  .00001

YES

代码如下:

 #include<cstdio>
#include<cstring>
#define MAX 20000
char a[MAX],b[MAX];
char ra[MAX],apoint[MAX],
rb[MAX],bpoint[MAX];
void func(char *a,char *ra,char *apoint)
{
int i=,k=;
bool flag=true;
int len=strlen(a);
if(*a=='+')i++;
else if(a[]=='-')
{
ra[k++]='-' ;
i=k;
}
for( ; a[i]==''&&i<len ; i++ ); for( ;a[i]!='.'&&i<len ; i++ )
{
ra[k++] = a[i] ;
}
int j;
a[i]=='.'? i++ : i ;
for(j=len-;a[j]==''&&j>=i;j--); for(k= ; i<=j ; i++)
{
apoint[k++]=a[i];
}
} int main( void )
{
while(scanf("%s%s",a,b)!=EOF)
{
memset(ra,'\0',sizeof ra);
memset(apoint,'\0',sizeof apoint);
memset(rb,'\0',sizeof rb);
memset(bpoint,'\0',sizeof bpoint);
func(a,ra,apoint);
func(b,rb,bpoint);
if(strcmp(ra,rb)==&&strcmp(apoint,bpoint)==)
puts("YES");
else if((*rb=='-'&&*(rb+)=='\0')&&strcmp(apoint,bpoint)==)
puts("YES");
else if(*ra=='-'&&*(ra+)=='\0'&&strcmp(apoint,bpoint)==)
puts("YES");
else
puts("NO");
}
return ;
}

HDUOJ-----A == B ?的更多相关文章

  1. hduoj 1455 && uva 243 E - Sticks

    http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...

  2. hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...

  3. hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup

    hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...

  4. hdu-oj 1874 畅通工程续

    最短路基础 这个题目hdu-oj 1874可以用来练习最短路的一些算法. Dijkstra 无优化版本 #include<cstdio> #include<iostream> ...

  5. C#版 - HDUoj 5391 - Zball in Tina Town(素数) - 题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. HDUoj 5 ...

  6. C++版 - HDUoj 2010 3阶的水仙花数 - 牛客网

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C++版 - ...

  7. HDUOJ题目HTML的爬取

    HDUOJ题目HTML的爬取 封装好的exe/app的GitHub地址:https://github.com/Rhythmicc/HDUHTML 按照系统选择即可. 其实没什么难度,先爬下来一个题目的 ...

  8. hduoj 1251 统计难题

    http://acm.hdu.edu.cn/showproblem.php?pid=1251 统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory ...

  9. hduoj 1286 找新朋友

    http://acm.hdu.edu.cn/showproblem.php?pid=1286 找新朋友 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...

  10. hduoj 1285 确定比赛名次

    http://acm.hdu.edu.cn/showproblem.php?pid=1285 确定比赛名次 Time Limit: 2000/1000 MS (Java/Others) Memory ...

随机推荐

  1. android获取sd卡路径方法

    public String getSDPath(){  File sdDir = null;  boolean sdCardExist = Environment.getExternalStorage ...

  2. JavaScript-undefined与null区别

    JavaScript中的null在其他编程语言中也很常见,但是JavaScript在设计的过程中null自动转换为0,为了更好表示空,这个时候undefined出现了,null通过typeof结果是“ ...

  3. CSS-设置Footer始终在页面底部

    Footer顾名思义页脚,如果内容多的时候在底部时感官很好,但是当内容变少(无法撑开一屏的时候)footer不固定在底部,影响美观,对于已经从事前端工作的工作的来说应该是比价工作中入门级别的问题了,由 ...

  4. winrar5.50去广告教程(仅供学习使用)

    https://blog.csdn.net/EnigmCode/article/details/78328873 第一步:到WinRAR官网www.rarlab.com下载自己需要的版本,我这里选择C ...

  5. QuickXDev插件自己主动升级后player no exist

      昨晚上QuickXDev插件执行还ok,今天打开电脑启动sublime text2后.右键run with player提示player no exist watermark/2/text/aHR ...

  6. mysql开启日志sql语句

    #查看日期情况 #show variables like '%general%'; #开启日志 #SET GLOBAL general_log = 'On'; #指定日志文件 #SET GLOBAL ...

  7. 【Spark】Spark-reduceByKey-深入理解

    Spark-reduceByKey-深入理解 spark.apache.org_百度搜索 Apache Spark™ - Lightning-Fast Cluster Computing reduce ...

  8. 解决PHP使用CVS导出Excel乱码问题

    在使用PHP生成CVS文件后通过Excel打开发现中文全部变成了乱码,之前在我本地win08通过WPS正常的,但上传到服务器Linux在服务器上测试出现了乱码 一开始以后是Linux的问题但后来测试时 ...

  9. clearfix 兼容IE6/IE7,解决ie6/ie7下多出一行的问题,bootstrap的clearfix的bug

    .clearfix:before, .clearfix:after { content: "."; display: block; height: ; overflow: hidd ...

  10. 使用Nexus管理maven仓库,setting文件理解

    来到新公司对很多陌生的技术一头雾水,以前在工作中没有真正使用过maven,于是强迫自己蛋定下来一个一个的突破,下面是我对maven的setting配置文件的理解,由于是现学的,难免可能会理解偏差,还请 ...