欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

java編寫一個(gè)含有100個(gè)隨機(jī)值的文本,且從文本中讀回?cái)?shù)據(jù)并以升序顯示數(shù)據(jù)

import java.io.*;
import java.util.*;
public class WriteArray
{
    public static void main(String[] args) throws Exception
    {
        System.out.println("請(qǐng)輸入文件名");
        Scanner fileName=new Scanner(System.in);
        File file=new File(fileName.nextLine());

        if(!file.exists())//判斷文件是否存在
        {
            PrintWriter output=new PrintWriter(file);
            Random r=new Random();
            for(int i=0;i<100;i++)
            {
                output.print(r.nextInt(1000)+" ");
            }
            output.close();
        }
        else
        {
            Scanner input=new Scanner(file);
            int[] arr =new int[100];
            int i=0;
            while (input.hasNext())//如果還有數(shù)據(jù)讀取,返回true
            {
                arr[i++]=input.nextInt();
            }
            input.close();
            Arrays.sort(arr);//升序排列
            for(i=0;i<arr.length;i++)
            {
                if(i%10==9)//換行輸出
                {
                    System.out.println(arr[i]);
                }
                else
                {
                    System.out.print(arr[i]+"\t");
                }
            }
        }
    }
}

分享名稱:java編寫一個(gè)含有100個(gè)隨機(jī)值的文本,且從文本中讀回?cái)?shù)據(jù)并以升序顯示數(shù)據(jù)
文章位置:http://www.chinadenli.net/article34/jdjppe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)域名注冊(cè)外貿(mào)建站面包屑導(dǎo)航網(wǎng)站建設(shè)自適應(yīng)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管