zoukankan      html  css  js  c++  java
  • HDU1106

    为了给学弟学妹讲课,我又水了一题……

      1: import java.util.*;
    
      2: import java.io.*;
    
      3: 
    
      4: public class HDU1106 
    
      5: {
    
      6:     public static void main(String[] args)
    
      7:     {
    
      8:         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
      9:         String s;
    
     10:         while((s=br.readLine())!=null)
    
     11:         {
    
     12:       //去掉字符串中空格,防止useDelimiter连续读取整数出错
    
     13:             Scanner sc = new Scanner(s.trim());
    
     14:             int k = 0;
    
     15:             int a[];
    
     16:             a=new int[1001];
    
     17:       //匹配正则表达式,5+表示匹配一个或多个5,不会产生空字符
    
     18:             sc.useDelimiter("5+");
    
     19:             while(sc.hasNextInt())
    
     20:                 a[k++]=sc.nextInt();
    
     21:             sc.close();
    
     22:             Arrays.sort(a,0,k);
    
     23:             for(int i=0;i<k;i++)
    
     24:             {
    
     25:                 if(i==k-1)
    
     26:                     System.out.println(a[i]);
    
     27:                 else
    
     28:                     System.out.print(a[i]+" ");
    
     29:             }
    
     30:         }
    
     31:     }
    
     32: }
    while(sc.hasNext()) {
        if(sc.hasNextInt()) {
            //do sth
        }else {
        //直接跳过
            next();
        }
    }
  • 相关阅读:
    react实现拖拽
    JS实现判断滚动条滚到页面底部并执行事件的方法
    获取地址中的参数 封装在params对象里面
    git常用命令
    Linux定时任务Crontab命令详解
    tars 部署
    tars 问题汇总
    Mac
    http head
    SSL
  • 原文地址:https://www.cnblogs.com/hxsyl/p/3236590.html
Copyright © 2011-2022 走看看