herrDeng網內搜尋

自訂搜尋

Ads

2015年12月11日 星期五

程式設計練習1

請用SecureRandom產生100個整數亂數值為[0,9]。 請計算每個數值出現的次數。

25 則留言:

A10433015 提到...

import java.util.Random;

public class aa { public static void main(String[] args) { Random aa = new Random(); int[] b= new int [10]; int []a=new int [100]; int c; for(int i=0;i<a.length;i++){ c=a[i]=aa.nextInt(10); System.out.print(a[i]+"--"); b[c]++; } System.out.println(); for (int s=0;s<b.length;s++) System.out.println(s+"---"+b[s]); }

}

a10433013 提到...

import java.security.SecureRandom;import java.util.*;public class abc { public static void main(String[] args) { SecureRandom input=new SecureRandom(); int x[]=new int[100]; int y=0,a=0,s=0,d=0,f=0,g=0,h=0,j=0,k=0,l=0; for(int i=0;i<x.length;i++){ x[i]=input.nextInt(9); System.out.print("x=["+x[i]+"]"+"\t"); if(i%10==9)System.out.println(); if(x[i]==0) y++; if(x[i]==1) a++; if(x[i]==2) s++; if(x[i]==3) d++; if(x[i]==4) f++; if(x[i]==5) g++; if(x[i]==6) h++; if(x[i]==7) j++; if(x[i]==8) k++; if(x[i]==9) l++; } System.out.println("0出現次數="+y); System.out.println("1出現次數="+a); System.out.println("2出現次數="+s); System.out.println("3出現次數="+d); System.out.println("4出現次數="+f); System.out.println("5出現次數="+g); System.out.println("6出現次數="+h); System.out.println("7出現次數="+j); System.out.println("8出現次數="+k); System.out.println("9出現次數="+l); }}

A10433018 提到...

package rpg;import java.security.SecureRandom;public class fgh {

public static void main(String[] args) { SecureRandom x=new SecureRandom(); int y[]=new int[100]; int c[]=new int[10]; int a; for(int i=0;i<y.length;i++){ a=y[i]=x.nextInt(10); System.out.println(a); c[a]++; } for(int v=0;v<c.length;v++) System.out.println(v+">>>>"+c[v]); }}

A10433006 提到...

import java.security.*;public class a1211 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); }

}

}

a10433019 提到...

import java.security.SecureRandom;import java.util.Arrays;

public class a1211 { public static void main(String[] args) { SecureRandom rnd= new SecureRandom(); int []a=new int[100]; int []count=new int[10]; int y; for (int i = 0; i<a.length; i++) { y=a[i]=rnd.nextInt(10); System.out.print(y+",\t"); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); }

}





}

a10433029 提到...

import java.security.SecureRandom;

public class exc29 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int []x=new int[100]; int []count=new int[10]; int y; for(int i=0; i<x.length; i++ ){ y=x[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

}

B10133007 提到...

import java.security.*;

public class ex01 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int []a=new int[100]; int []count=new int[10]; int y; for(int i=0; i<a.length; i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9) System.out.println(); count[y]++; } System.out.println(); for(int j=0; j<count.length; j++){ System.out.println(j+"我出現的次數為:"+count[j]); } }}

A10433008 提到...

import java.security.SecureRandom;

public class ex412011 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

}

A10433004 提到...

import java.util.Random;
public class ex1 {
public static void main(String[] args) {
Random rnd=new Random();
int []x=new int[100];
int []count=new int[10];
int y;
for(int i=0;i<x.length; i++){
y=x[i]=rnd.nextInt(10);
System.out.print(y+",\t");
if(i%10==9) System.out.println();
count[y]++;
}
System.out.println();
for(int a=0;a<count.length;a++){
System.out.println(a+"出現次數:"+count[a]);
}}}
 

A10433011 提到...

package zz;

import java.util.Random;

public class z1 { public static void main(String[] args) { int []a=new int[100]; int []count=new int [10]; int y; Random rnd=new Random(); for (int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+"\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數"+count[j]); } }}

A10433007 提到...

package hello;

import java.security.SecureRandom;

public class ex2 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

}

A10433010 提到...

package hello;

import java.security.SecureRandom;

public class ex2 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

}

A10433014 提到...

package hello;

import java.security.SecureRandom;

public class ex2 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

}

匿名 提到...

import java.security.SecureRandom;public class a1211 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+"\t"); if(i%10==9) System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數"+count[j]); }

}

}

A10433028 提到...

import java.security.SecureRandom;

public class dsa {

public static void main(String[] args) { SecureRandom AD=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=AD.nextInt(10); System.out.print(y+" "); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

A10433001 提到...

import java.security.SecureRandom;

public class dsa {

public static void main(String[] args) { SecureRandom AD=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=AD.nextInt(10); System.out.print(y+" "); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

A10433038 提到...

import java.security.SecureRandom;

public class dsa {

public static void main(String[] args) { SecureRandom AD=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=AD.nextInt(10); System.out.print(y+" "); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

A10433038 提到...

import java.security.SecureRandom;



public class dsa {



public static void main(String[] args) { SecureRandom AD=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=AD.nextInt(10); System.out.print(y+" "); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

A10433038 提到...

import java.security.SecureRandom;



public class dsa {



public static void main(String[] args) { SecureRandom AD=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=AD.nextInt(10); System.out.print(y+" "); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

10433020 遲 提到...

package hello;

import java.security.SecureRandom;

public class ex2 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

}

A10433043 提到...

package hello;

import java.security.SecureRandom;

public class ex2 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

}

A10433022 遲 提到...

package hello;

import java.security.SecureRandom;

public class ex2 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

}

A10433036 提到...

import java.security.SecureRandom;

public class exc29 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int []x=new int[100]; int []count=new int[10]; int y; for(int i=0; i<x.length; i++ ){ y=x[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

}

a10433024 提到...

import java.security.SecureRandom;public class ex2 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+"\t"); if(i%10==9) System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數"+count[j]); }

}

}

B10133189 提到...

import java.security.SecureRandom;

public class dsa {

public static void main(String[] args) { SecureRandom AD=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=AD.nextInt(10); System.out.print(y+" "); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

Related Posts Plugin for WordPress, Blogger...

熱門文章