public static void main(String[] args) { test(100); } public static void test(int num){ int i=0; while(i<num){ System.out.print(++i); if(i!=100){ System.out.print("、"); } } System.out.println(); int j=0; do{ System.out.print(++j); if(j!=100){ System.out.print("、"); } }while(j<100); System.out.println(); for(int k=0;k<100;){ System.out.print(++k); if(k!=100){ System.out.print("、"); } } }
public static void main(String[] args) { test(); } public static void test(){ int num[] =new int[25]; for(int i=0;i<25;i++){ Random r=new Random(); int n=r.nextInt(); num[i]=n; if(i>0){ compare(num[i-1],num[i]); } } } public static void compare(int n1,int n2){ //System.out.println(n1+"、"+n2+"\n n1>n2:"+(n1>n2)+"\t"+"n1==n2:"+(n1==n2)+"\t"+"n1<n2:"+(n1<n2)); if(n1>n2){ System.out.println(n1+"大于"+n2); }else if(n1<n2){ System.out.println(n1+"小于"+n2); }else { System.out.println(n1+"等于"+n2); } }
public static void main(String[] args) { test(); } public static void test(){ int num[] =new int[2]; int i=0; boolean flag=false; while(true){ Random r=new Random(); int n=r.nextInt(); if(flag){ num[i]=n; compare(num[0],num[1]); }else{ flag=true; num[i]=n; } i=i==0?1:0; } } public static void compare(int n1,int n2){ //System.out.println(n1+"、"+n2+"\n n1>n2:"+(n1>n2)+"\t"+"n1==n2:"+(n1==n2)+"\t"+"n1<n2:"+(n1<n2)); if(n1>n2){ System.out.println(n1+"大于"+n2); }else if(n1<n2){ System.out.println(n1+"小于"+n2); }else { System.out.println(n1+"等于"+n2); } }
public static void main(String[] args) { test(33); } public static boolean test(int num){ for(int i=2;i<num;i++){ if(num%i==0){ System.out.println(num+" 不是素数"); return true; } } System.out.println(num+" 是素数"); return false; }
原文:http://blog.csdn.net/ztt_1119/article/details/40741463