测试发布 代码

// http://acm.hdu.edu.cn/showproblem.php?pid=2054  A==B?
#include
  
  
   
   
#include<
   
   string.h>
#include
   
   

    
    const 
    
    long  maxn = 100024;

    
    /*

    
    要考虑的情况  1,10)、(100,100.00)、(0001, 01.0)、(01.1001 , 1.101)、(1.0100,1.01)

    
    */

    
    void partition_string(
    
    char _a[],
    
    char _a1[],
    
    char _a2[])
{
    
    
    char *str;
    
    
    int i,j,len;
    str = strchr(_a,
    
    '.');
    
    // 
    
    
    if(str!=NULL)
    {
        len = strlen(_a);
        strncpy(_a1,_a,(str-_a)/
    
    sizeof(
    
    char));
        _a1[(str-_a)/
    
    sizeof(
    
    char)] = 
    
    '/0';
        
        
    
    for(j = 0, i = (str-_a)/
    
    sizeof(
    
    char) + 1;i< len;i++,j++)
            _a2[j] = _a[i];
        _a2[j] = 
    
    '/0';
    }
    
    
    else 
    {
        strcpy(_a1,_a);
        strcpy(_a2,
    
    "0");
    }

}


    
    int check(
    
    char _str[])
    
    // 用于去掉 小数区的0
{    

    
    
    int i,len = strlen(_str);
    
    
    for(i = len-1;i>=0;i--)
    {
        
    
    if(_str[i] == 
    
    '0') _str[i] = 
    
    '/0';
        
    
    else 
    
    return i;
        
    
    //if(_str[i] != '0' ) break;
    }

    
    
    return -1;
}

    
    int del(
    
    char _str[])
    
    // 用于去掉 整数区的0
{    
    
    
    
    int i,len = strlen(_str);
    
    
    for(i= 0;i < len && _str[i]==
    
    '0';i++)
        ;
    
    
    return i; 
    
    //返回 第一个不等于0的下标
}



    
    int main()
{
    
    
    //freopen("in.txt","r",stdin);
    
    
    char a[maxn],b[maxn],temp[10];

    
    
    char a1[maxn],a2[maxn],b1[maxn],b2[maxn];
    
    
    
    while(scanf(
    
    "%s%s",a,b)!=EOF)
    {
        
    
    //memset(a1,NULL,500);memset(a2,NULL,500);
        
    
    //memset(b1,NULL,500);memset(b2,NULL,500);
        partition_string(a,a1,a2);partition_string(b,b1,b2);
        check(a2),check(b2);
        
    
    //a1=,b1=;
        
    
    if(strcmp(a1+del(a1),b1+del(b1)) ==0 && strcmp(b2,a2)==0) 
    
    // strcmp(a1+del(a1),b1+del(b1))就可以很好的比较
            printf(
    
    "YES/n");
        
    
    else printf(
    
    "NO/n");
        
    
    //memset(a,NULL,500);memset(b,NULL,500);

    }
    
    
    return 0;
}
   
   
  
  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值