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. iOS开发-简单抽奖

    路过商场,看过抽奖感觉挺有意思的,商场进行抽奖活动,三个奖项,一等奖的概率1/10,二等奖的概率的3/10,三等奖的概率是6/10,具体奖品我没仔细看,回来随便练手了一下,思考了一下,奖品分为10份, ...

  2. java 反射机制--根据属性名获取属性值

    1.考虑安全访问范围内的属性,没有权限访问到的属性不读取 /** * 根据属性名获取属性值 * * @param fieldName * @param object * @return */ priv ...

  3. windows及linux环境下永久修改pip镜像源的方法

    一.在windows环境下修改pip镜像源的方法(以python3.5为例) (1):在windows文件管理器中,输入 %APPDATA% (2):会定位到一个新的目录下,在该目录下新建pip文件夹 ...

  4. JPA(四):EntityManager

    Persistence Persistence类使用于获取EntityManagerFactory实例,该类包含一个名为createEntityManagerFactory的静态方法. // 创建En ...

  5. CSS中的图片路径问题

      CSS中的背景图片写了相对路径,为什么不显示那?   [解决方法] CSS中的背景图片路径应该写成相对于当前CSS文件的路径,而不是针对网站根目录的相对路径.

  6. [Algorithm] Delete a node from Binary Search Tree

    The solution for the problem can be divided into three cases: case 1: if the delete node is leaf nod ...

  7. Android Volley 库的使用

    本文内容 什么是 Volley 库 Volley 能做什么 Volley 架构 环境 演示 Volley 库的使用 参考资料 Android 关于网络操作一般都会介绍 HttpClient 以及 Ht ...

  8. MicrosoftAjax.js

    MicrosoftAjax.js下载 Function.__typeName = "Function"; Function.__class = true; Function.cre ...

  9. Getting in Line UVA 216

     Getting in Line  Computer networking requires that the computers in the network be linked. This pro ...

  10. SHELL 循环获取日期以及FOR使用

    ;i<=;i++)); do PYTHONPATH=lib/ bin/cupid -c conf/config.cfg -u http://shop33220311.taobao.com/?tb ...