zoukankan      html  css  js  c++  java
  • HDU 1106 排序

    特殊数据

    0051231232050775
    555556
    1555556
    125
    55552345891
    1234
    12345531232

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #define N 1005
    using namespace std;
    char ch[N];
    int main()
    {
        freopen("C:\Users\super\Documents\CB_codes\in.txt", "r", stdin);
       // freopen("C:\Users\super\Documents\CB_codes\out.txt","w",stdout);
        while(~scanf("%s",ch)){
            int len=strlen(ch);
    
            int a[N]={0},j=0,mul=1;
            for(int i = len-1; i >= 0; i--){
                if(ch[i] == '5'){
                    continue;
                }
                else{
                    while(ch[i] != '5'){
                        if(i < 0)
                            break;
                        a[j] += (ch[i]-'0')*mul;
                        mul *= 10;
                        i --;
                    }
                    mul = 1;
                    j ++;
                }
            }
            sort(a,a+j);
            printf("%d",a[0]);
            for(int i=1;i<j;i++){
                printf(" %d",a[i]);
            }
            printf("
    ");
        }
    
    
        fclose(stdin);
        return 0;
    }
    
    ---------------- 人们生成的最美好的岁月其实就是最痛苦的时候,只是事后回忆起来的时候才那么幸福。
  • 相关阅读:
    vb笔记
    linux学习笔记
    linnux--shell
    # 用类来封装动态数组:分文件编写
    面向对象
    c++2
    c++1
    答疑:指针数组字符串
    文件操作
    用函数封装实现对一个数组增删改查
  • 原文地址:https://www.cnblogs.com/livelihao/p/5288867.html
Copyright © 2011-2022 走看看