zoukankan      html  css  js  c++  java
  • HDOJ 1106

    注意结尾处补上个5,很简单的水题

    #include <iostream>
    #include <cstring>
    #include <algorithm>

    using namespace std;

    int nth=0;

    void function(char* s,int& a,int wei)
    {
        a=0;
        for(int i=0;i<wei;i++)
        {
            int e=1;
            for(int j=0;j<wei-1-i;j++)
            {
                e*=10;
            }
            a+=(s-48)*e;
        }

    }


    int main()
    {
        char str[1005];
        int a[800];
        while(cin>>str)
        {

            int len=strlen(str);
            str[len]='5';
            str[len+1]=0;

            len=strlen(str);

            nth=0;
            int wei=0;
            char ss[14];
            memset(ss,99,sizeof(ss));

            for(int i=0;i<len;i++)
            {
                if(str!='5')
                {
                    ss[wei]=str;
                    wei++;
                }
                else if(str=='5')
                {
                    ///if WEI = 0 break!!
                    if(wei!=0)
                    {
                        function(ss,a[nth],wei);
                        nth++;
                    }
                    wei=0;
                    memset(ss,99,sizeof(ss));
                }
            }

            sort(a,a+nth);
            for(int i=0;i<nth;i++)
            {
                cout<<a;
                if(i!=nth-1)
                    cout<<" ";
            }
            cout<<endl;

        }

        return 0;
    }

  • 相关阅读:
    使用VS2015将解决方案同步更新到Github上
    SQL Server循环
    OSPF
    OPSF
    OSPF
    pandas更换index,column名称
    pandas的时间戳
    pandas选择单元格,选择行列
    BGP
    BGP
  • 原文地址:https://www.cnblogs.com/CKboss/p/3351110.html
Copyright © 2011-2022 走看看