2054A==B?hdu

自己做这道题第一次用到了strchr这个函数;

strchr函数原型:extern char *strchr(const char *s,char c);查找 字符串s中首次出现字符c的 位置

A == B ?

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


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
AC代码:
#include<stdio.h>
#include<string.h>
#define M 1000000
char s[M];
char p[M];
int fun(char *p)
{
    int n,i,j;
    n=strlen(p);
    if(strchr(p,'.')!=NULL)
    {
    for(i=n-1;p[i]=='0';i--);
    if(p[i]=='.')
    p[i]='\0';
    else
    p[i+1]='\0';
    }
    for(i=0;p[i]=='0'&&p[i+1]!='\0';i++);
    return i;
}
int main()
{
    while(~scanf("%s %s",s,p))
    {
                     int m,k,t;
                     int i,j;
                     for(i=fun(s),j=fun(p);s[i]!='\0'&&p[j]!='\0';i++,j++)
                     {
                                                             if(s[i]!=p[j])
                                                             {
                                                                           //printf("NO\n");
                                                                           break;
                                                             }
                     }
                     if(s[i]=='\0'&&p[j]=='\0')
                     printf("YES\n");
                     else
                     printf("NO\n");
                    
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值