
Java技术 0-10 11-20 21-30……91—100分组后随机抽取两个不同的偶数
Java技术0-1011-2021-30……91—100分组后随机抽取两个不同的偶数1打印出来2求和3求积类似于下图这个成语编码我的作业求大神帮我...
Java技术 0-10 11-20 21-30……91—100分组后随机抽取两个不同的偶数 1打印出来 2求和3求积 类似于下图这个成语编码 我的作业 求大神帮我
展开
2个回答
展开全部
public class ArrayTest {
public static void main(String[] args) {
int arr[][] = new int[10][10];
for (int i = 0; i < 10; i++)
for (int j = 0; j < 10; j++)
arr[i][j] = 1 + j + i * 10;
int num1, num2;
while(true){
if((num1=arr[(int)(Math.random()*10)][(int)(Math.random()*10)]) % 2 == 0 &&
(num2=arr[(int)(Math.random()*10)][(int)(Math.random()*10)]) % 2 == 0 ){
System.out.println("数字1是 :" + num1 + " 数字2是: " + num2);
System.out.println("两数之和是: " + (num1 + num2));
System.out.println("两数之积是: " + (num1 * num2));
break;
}
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询