标签:
package demo;
import javax.swing.JOptionPane;
public class RandomAdd {
public static void main(String[] args){
int random[]=new int[10];
int sum=0;
for(int i =0;i < random.length;i++)
{
int val=(int)(Math.random()*100+1);
random[i] = val;
}
String output = new String();
for(int i =0;i < random.length;i++)
{
output+=random[i]+‘0‘;
output+=" ";
}
for(int i = 0;i < random.length;i++)
{
sum += random[i];
}
output += "\n所有数的和为:" + sum;
JOptionPane.showMessageDialog(
null, output, "Results",
JOptionPane.PLAIN_MESSAGE );
}
}
结果:
标签:
原文地址:http://www.cnblogs.com/zczhtml/p/4924777.html