zoukankan      html  css  js  c++  java
  • HDU2054 A==B?

    题目地址:HDU2054

    将读出的浮点数保存在字符数组中(声明大小或者new一个),除去前置零和小数点后的后置零,若小数点后数全为零,则连小数点一起去掉。
     注意:去掉后置零时 *p--=0 的表达方式。
    

    代码:

    #include<iostream>
    #include<cstring>
    #include<cstdio>
    using namespace std;
    void A(char *s)
    {
        int len=strlen(s);
        char *p=s+len-1;
        if(strchr(s,'.'))
           while(*p=='0')*p--=0;
        if(*p=='.') *p=0;
    }
    int main()
    {
        char m[100000],n[1000000];
        while(scanf("%s%s",&m,&n)!=EOF)
        {
           char *pm=m;
           char *pn=n;
           while(*pm=='0') pm++;
           while(*pn=='0') pn++;
           A(pm);A(pn);
           if(strcmp(pm,pn))
              cout<<"NO"<<endl;
           else cout<<"YES"<<endl;
        }
    }
    
  • 相关阅读:
    css 基础
    css 基础-1
    html 入门2-表
    CMDB (后台管理) CURD 插件
    序列化
    AES(高级加密)
    API验证
    数据库取时间(分组)
    用户权限 (知识点)
    xss 过滤
  • 原文地址:https://www.cnblogs.com/Wu-Shi/p/5410073.html
Copyright © 2011-2022 走看看