Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我们这里的java要求以Main为类名.In Reply To:這是我做的第一題﹐老是Compile Error﹐不知什么原因。。。。。。 Posted by:BachelorLrz at 2007-08-02 21:30:15 > import java.util.Scanner; > class UglyNumbers{ > public static void main(String[] args) > { > short[] outArray = new short[1000]; > int i = 0; > while (true) > { > Scanner sc = new Scanner(System.in); > short in = sc.nextShort(); > outArray[i] = getUglyNamber(in); > if(in == 0) break; > i++; > } > for(int j=0;j<i;j++) > { > System.out.println(outArray[j]+""); > } > } > public static short getUglyNamber(short in) > { > short temp = 1; > short result = 1; > while(true) > { > if(result%2==0 || result%3==0 || result%5==0) temp++; > if(temp >= in) break; > result++; > } > return result; > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator