码迷,mamicode.com
首页 > 其他好文 > 详细

作业-数字

时间:2017-12-10 21:32:27      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:dex   new   nal   input   分享图片   log   oid   class   body   

package fiveint;  
import java.util.InputMismatchException;  
import java.util.Scanner;  
public class Five{  
    public static void main(String[] args) {  
        System.out.println("请输入5个整数,输入0结束:");  
        int a[]=new int[5];  
        Scanner put=new Scanner(System.in);  
        try {  
            int n;  
            for(int i=0;(n=put.nextInt())!=0;i++) {  
                a[i]=n;  
            }  
            }  
            catch(InputMismatchException e)   
            {  
                System.out.println("输入有误,请输入整数。");  
            }  
            catch(ArrayIndexOutOfBoundsException e)  
            {  
                System.out.println("输入有误,请输入5个整数。");  
            }  
            finally {  
                System.out.println("谢谢使用本程序!");  
                  
            }  
        }  
    }  

  技术分享图片

 

作业-数字

标签:dex   new   nal   input   分享图片   log   oid   class   body   

原文地址:http://www.cnblogs.com/spsglz/p/8017915.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!