大整数排序 为什么提示没有循环测试用例啊?

import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
    public static void main(String[] args){
      	try{
            BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
            String str;
            while((str=reader.readLine())!=null){
                int n=Integer.parseInt(str);
                //保证测试的每组数据个数在1到10之间
                if(n>=1 && n<=10)
                {
                    int i=0,s=0;
                    long[] result=new long[n];
                    //用数组存储输入的多个数据
                    while(i<n)
                    {
                        result[i]=Long.parseLong(reader.readLine());
                        i++;
                    }
                    //然后对数组由小到大排序
                    for(int j=0;j<n;j++)
                    {
                        for(int k=n-1;k>j;k--)
                        {
                            if(result[j]>result[k])
                            {
                                long temp=result[j];
                                result[j]=result[k];
                                result[k]=temp;
                            }
                        }
                    }
                    //输出数组元素
                    while(s<n){
                        System.out.println(result[s]);
                        s++;
                    }
                }
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
我在eclipse上运行能通过,并且能多次循环呀!

全部评论
没看懂楼主代码,你可以参考一下别人通过的代码啊 大整数排序通过的代码
点赞 回复 分享
发布于 2017-01-13 10:33

相关推荐

流浪的神仙:无恶意,算法一般好像都得9硕才能干算法太卷啦
点赞 评论 收藏
分享
04-09 09:47
门头沟学院 Java
Arbelite_:2-3k,这工资还不如去摇奶茶
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务