zoukankan      html  css  js  c++  java
  • Help him--hdu5059(模拟 大坑)

    http://acm.hdu.edu.cn/showproblem.php?pid=5059

    直接说可能出现的情况

    #include <iostream>
    #include <cstring>
    #include <algorithm>
    #include <queue>
    #include <cstdio>
    #include <cstdlib>
    #include <cctype>
    #include <cmath>
    
    using namespace std;
    #define memset(a,b) memset(a,b,sizeof(a))
    #define N 1100000
    typedef long long  ll;
    
    int main()
    {
        char str[110];
        ll a,b,c;
       while(gets(str))
        {
            int flag=0;
            scanf("%lld %lld",&a,&b);
            int len=strlen(str);
            if(len==0)///字符串为空串是非法
                flag=1;
            if(len>13)///如果字符串长度大于13就一定是非法
            {
                flag=1;
            }
            if((len==1 && str[0]=='-') || (len==2 && str[0]=='-' && str[1]=='0'))///'-','-0'都是非法
            {
                flag=1;
            }
            int i=0;
            if(str[0]=='-')
                i++;
            c=0;
            for( ;str[i];i++)
            {
                if(str[i]<'0' || str[i]>'9')
                {
                    flag=1;
                    break;
                }
                c=c*10+(str[i]-'0');
            }
            if(flag==1)
                puts("NO");
            else if(str[0]=='-')
            {
                c=-c;
                if(c>=a && c<=b && str[1]!='0')
                {
                    puts("YES");
                }
                else
                    puts("NO");
            }
            else
            {
                if(c>=a && c<=b && str[0]=='0' && len==1)
                    puts("YES");
                else if(c>=a && c<=b && str[0]!='0')
                {
                    puts("YES");
                }
                else
                    puts("NO");
            }
            getchar();
        }
        return 0;
    }
    /*
    -0
    -5 5
    */
  • 相关阅读:
    python模拟shell
    10.LIKE 操作符
    9.TOP 子句--mysql limit
    8.INSERT INTO 语句 UPDATE 语句
    7.ORDER BY 子句
    6.AND & OR 运算符
    5.WHERE 子句
    4.SELECT DISTINCT 语句
    3.SELECT 语句
    2.sql分类
  • 原文地址:https://www.cnblogs.com/linliu/p/5394455.html
Copyright © 2011-2022 走看看