zoukankan      html  css  js  c++  java
  • NYOJ题目1162数字

    -------------------------------------

    我去写评测机的人好阴险啊竟然不让使用List....W( ̄_ ̄)W

    然后Java强大的APi根本挡不住的好伐.....

    用C写一大坨的java一行调用现成轮子搞定~

    AC代码:

     1 import java.io.BufferedReader;
     2 import java.io.IOException;
     3 import java.io.InputStreamReader;
     4 import java.util.Arrays;
     5 
     6 public class Main {
     7 
     8     public static void main(String[] args) throws IOException {
     9         
    10         BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
    11         
    12         int n=Integer.parseInt(reader.readLine());
    13         while(n-->0){
    14             int x[]=new int[100]; int index=0;
    15             char cs[]=reader.readLine().toCharArray();
    16             boolean lastNotZero=false;
    17             int value=0;
    18             for(int i=0;i<cs.length;i++){
    19                 if(cs[i]=='0'){
    20                     if(lastNotZero) x[index++]=value;
    21                     lastNotZero=false;
    22                     value=0;
    23                 }else{
    24                     lastNotZero=true;
    25                     value=value*10+cs[i]-'0';
    26                 }
    27             }
    28             if(value!=0) x[index++]=value;
    29             if(index==0){
    30                 System.out.println(0);
    31                 continue;
    32             }
    33             Arrays.sort(x,0,index);
    34             for(int i=0;i<index;i++) System.out.print(x[i]+" ");
    35             System.out.println();
    36         }
    37         
    38     }
    39     
    40 }

    题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=1162

  • 相关阅读:
    day74 作业
    day73 基表 表关联
    不知道第几次分享了
    day72 序列化家族
    day72 作业
    vscode
    vuex
    linux python3.7的安装和配置
    使用多线程分批发送短信代码,分割list
    docker 容器里使用crontab不生效
  • 原文地址:https://www.cnblogs.com/cc11001100/p/5879456.html
Copyright © 2011-2022 走看看