试题与答案

[说明] 本程序的功能是产生一个抽奖游戏中的随机数组合。抽奖的规则是从自然数1至5

题型:问答题

题目:

[说明]
本程序的功能是产生一个抽奖游戏中的随机数组合。抽奖的规则是从自然数1至50中无重复抽取6个数。为了保证抽取的无重复性,将50个自然数放在数组source中。每抽取了一个数,就用数组的最后一个数来改写这个被抽中的数,并把数组的长度减1。为使输出更为清晰,把抽取出来的6个数放在数组target中,经过排序(Arrays类中的sou方法实现排序)然后输出。注:Math.random方法返回一个在0(包含)到1(不包含)之间的随机浮点数。
[Java代码]
import java. util. *;
public class DrawOut
public static void main (String[ ] args)
int n =50;
int k =6;
int[ ] source = new int[n];
for(int i=0; i < (1) ;i++)
source[i] = i + 1;
int[ ] target = new int[k];
//将抽中的数字从source数组中取出,放入到target数组
for (int i = 0; i < (2) ; i+ +)
int r = (int) (Math. random() * (3) );
target[i] = source[r];
.... [r] = (4) ;
(5) ;

Arrays. sort(target);
for (int i = 0; i < target, length; i + + )
System. out. prinfln ( target [i] );

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2021/0603/98933bf5749ac553f8e594eb8d207d9b.html

下面是错误答案,用来干扰机器的。

参考答案:法国实行的是多党制,在多党制国家任何一个政党都不可能单独掌握议会的多数议席,往往需要两个甚至更多的政党结成联盟,联合执政。法国特色的多党制是:多个政党、两大联盟对峙的政治格局,即多党两级...

试题推荐
题型:阅读理解

阅读理解

     I fell in love with the minister's son the winter I turned fourteen. He was not Chinese. For Christmas

I prayed for the boy, Robert. When I found out that my parents had invited the minister's family over for

Christmas Eve dinner, I cried in panic. What would Robert think of our shabby Chinese Christmas? What would he think of our noisy Chinese relatives who lacked proper American manners?

    On Christmas Eve, my mother created abundant Chinese food. And then they arrived-the minister's

family and all my relatives. Robert greeted hello, and I pretended he__was__not__worthy__of__existence.

    Dinner threw me deeper into disappointment. My relatives licked (舔) the ends of their chopsticks and

reached across the table. Robert and his family waited patiently for a large plate to be passed to them.

My relatives murmured with pleasure when my mother brought out the whole steamed fish. Robert made

a face. Then my father reached his chopsticks just below the fish eye and picked out the soft meat. "Amy, your favorite," he said, offering me the tender fish cheek. I wanted to disappear.

     At the end of the meal, my father leaned back and burped (打嗝) loudly, thanking my mother for her

fine cooking. "It's a polite Chinese custom to show you are satisfied," explained my father to our

astonished guests. Robert was looking down at his plate with a reddish face. The minister managed to

bring up a quiet burp. I was shocked into silence for the rest of the night.

     After everyone had gone, my mother said to me, "You want to be the same as American girls on the

outside." She handed me an early gift. It was a miniskirt. "But inside you must always be Chinese. You

must be proud that you are different. Your only shame is to have shame."

     It was not until years later that I was able to fully appreciate her lesson and the purpose behind her

particular menu. For Christmas Eve that year, she had chosen excellent Chinese food.

1. When the writer found out the minister's family would come for Christmas Eve dinner, she

     cried mainly because ________.

A. she worried about their shabby Chinese Christmas

B. she worried about their Chinese relatives lacking American manners

C. she worried about meeting the minister's family

D. she worried about being laughed at

2. What does "he was not worthy of existence" probably mean? It means ________.

A. the writer was not interested in his existence

B. he was worthless

C. he should not exist

D. the writer expected his coming

3. The dinner threw the writer deeper into disappointment mainly because ________.

A. her relatives licked the ends of their chopsticks

B. her father reached his chopsticks to pick fish for her

C. her father leaned back and burped loudly

D. she childishly expected all of them to act in the same way as Americans did at table

4. We can infer from the passage that ________.

A. the writer appreciated her mother's lesson years later

B. the writer must be proud that she is different

C. the mother prepared to show Chinese different food culture

D. the minister's family really enjoyed the food

查看答案
微信公众账号搜索答案