[阅读: 333] 2005-11-05 02:47:20
public class BS {
// main method begins execution of Java application
public static void main( String args[] )
{
int value, frequency[] = new int[ 7 ];
for ( int time = 1; time <= 6000; time++ ) {
value = 1 + ( int ) ( Math.random() * 6 );
++frequency[ value ];
}
String output = "value\tFrequency";
// append frequencies to String output
for ( value = 1; value < frequency.length; value++ )
output += "\n" + value + "\t" + frequency[ value ];
System.out.print(output);
}
}