• 纸尿裤等纸制品新国标发布 2019-07-13
  • 世界杯期间在家撸串的正确姿势-热门标签-华商网数码 2019-07-10
  • 人工+智能新闻舆情大数据服务 2019-07-08
  • 最后的骑兵:解放军高原骑兵腰挎马刀热血冬训 2019-06-29
  • “一带一路”大学双创教育“和声正美” 2019-06-29
  • 落实河长制必须持之以恒 2019-06-22
  • 跟青岛人逛海边,聊上合 2019-06-18
  • 望远镜的眼睛有多大?这个参数很关键 2019-06-18
  • 人民日报召开创刊70周年读者座谈会 2019-06-09
  • 【改革印记——看中国发展】变迁印记,留下的是韵味现实 2019-05-31
  • [大笑]阿Q都是这么说的。。。。。。 2019-05-31
  • 曾祖红:天津欢乐谷二期将于6月30日对外开放 2019-05-28
  • 新发现:墨西哥发现恐龙新物种 2019-05-21
  • 为吸引中国游客 世界各国纷纷喊话:“我最懂你” 2019-05-21
  • 任天堂Switch九月开始收连线费 详细方案公开 2019-05-20
  • java中南大学livelab习题 - 下载本文

    青海11选五怎么中奖 www.skw3.com

    }

    (Game: locker puzzle) A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the students enter, the first student, denoted S1, opens every locker. Then the second student, S2, begins with the second locker, denoted L2, and closes every other locker. Student S3 begins with the third locker and changes every third locker (closes it if it was open, and opens it if it was closed). Student S4 begins with locker L4 and changes every fourth locker. Student S5 starts with L5 and changes every fifth locker, and so on, until student S100 changes L100. After all the students have passed through the building and changed the lockers,which lockers are open? Write a program to find your answer and display all open locker numbers separated by exactly one space.(Hint: Use an array of 100 Boolean elements, each of which indicates whether a locker is open (true) or closed (false). Initially, all lockers are closed.)

    学生与储物柜的问题,第一个学生打开所有的储物柜,第二个学生关闭每隔一个储物柜,第三个学生关闭每隔两个储物柜,以此类推,最后一个关闭最后一个储物柜,问最后哪些储物柜是开着的。 public class Exercise07_23 {

    public static void main(String[] args) { }

    (Sort characters in a string) Write a method that returns a sorted string using the following header: public static String sort(String s) For example, sort(\

    Write a test program that prompts the user to enter a string and displays the sorted string.

    import java.util.Scanner; public class Exercise07_34 {

    public static void main(String[] args) {

    Scanner sc=new Scanner(System.in); System.out.println(\String inputStr=sc.nextLine(); }

    for(int i=1;i<=100;i++) { }

    int count=0; for(int j=1;j<=i;j++) { }

    if(count%2!=0)

    System.out.print(i+\if((i%j)==0)

    count++;

    }

    System.out.println(); } }

    if(slot[j]>=(num_ball-i)) else

    System.out.print(\System.out.print(\

    26

    }

    (Use the Date class) Write a program that creates a Date object, sets its elapsed time to 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, and 100000000000, and displays the date and time using the toString() method, respectively.运用Data类,使逝去的时间为10000,100000,1000000,10000000,1000000000......显示日期和时间 import java.util.Date; public class Exercise09_03 {

    public static void main(String[] args) {

    System.out.println(\Date[] date=new Date[8]; date[0]=new Date(10000); date[1]=new Date(100000); date[2]=new Date(1000000); date[3]=new Date(10000000); date[4]=new Date(100000000); }

    sc.close();

    Character[] charList=new Character[inputStr.length()]; for(int i=0;i

    for(int i=0;i

    for(int i=0;i

    System.out.print(charList[i]); Character currentMin=charList[i]; int currentMinIndex=i;

    for(int j=i+1;j

    if(currentMinIndex!=i) { }

    charList[currentMinIndex]=charList[i]; charList[i]=currentMin;

    if(currentMin>charList[j]) { }

    currentMin=charList[j]; currentMinIndex=j;

    charList[i]=inputStr.charAt(i);

    27

    }

    (Use the Random class) Write a program that creates a Random object with seed 1000 and displays the first 50 random integers between 0 and 100 using the nextInt(100) method.运用RANDOM类,生成1000个数,显示前50个 0-100的整数

    public class Exercise09_04 { }

    (Stopwatch) Design a class named StopWatch. The class contains:

    ■ Private data fields startTime and endTime with getter methods.■ A no-arg constructor that initializes startTime with the current time.■ A method named start() that resets the startTime to the current time.■ A method named stop() that sets the endTime to the current time.■ A method named getElapsedTime() that returns the elapsed time for the stopwatch in milliseconds.

    Draw the UML diagram for the class and then implement the class. Write a test program that measures the execution time of sorting 100,000 numbers using selection sort.

    package homework; import java.util.Date; import java.util.Random; class StopWatch {

    private long startTime; }

    public static void main(String[] args) { Random rd=new Random(1000); for(int i=0;i<50;i++) { }

    System.out.println(rd.nextInt(100));

    }

    date[5]=new Date(1000000000); date[6]=new Date(10000000000L); date[7]=new Date(100000000000L); for(int i=0;i<8;i++) { }

    System.out.println(date[i]+\

    private long endTime; StopWatch() {

    Date dt=new Date();

    this.setStartTime(dt.getTime()); } void start()

    28

    {

    Date dt=new Date();

    this.setStartTime(dt.getTime()); } void stop() {

    Date dt=new Date();

    this.setEndTime(dt.getTime()); }

    long getElapsedTime() {

    return(this.getEndTime()-this.getStartTime()); } public long getStartTime() { return startTime; }

    public void setStartTime(long startTime) { this.startTime = startTime; }

    public long getEndTime() { return endTime;

    }

    public void setEndTime(long endTime) {

    this.endTime = endTime; }

    }

    public class Exercise09_06 {

    public static void main(String[] args) { StopWatch watch=new StopWatch(); int n=100000; int[] num=new int[n]; Random rd=new Random(); for(int i=0;i

    }

    watch.start(); for(int i=0;i

    for(int j=i+1;j

    29

    { if(max

    }

    }

    if(maxIndex!=i) { num[maxIndex]=num[i]; num[i]=max; }

    }

    watch.stop(); System.out.println();

    System.out.println(watch.getStartTime()); System.out.println(watch.getEndTime()); System.out.println(watch.getElapsedTime());

    }

    }

    30





  • 纸尿裤等纸制品新国标发布 2019-07-13
  • 世界杯期间在家撸串的正确姿势-热门标签-华商网数码 2019-07-10
  • 人工+智能新闻舆情大数据服务 2019-07-08
  • 最后的骑兵:解放军高原骑兵腰挎马刀热血冬训 2019-06-29
  • “一带一路”大学双创教育“和声正美” 2019-06-29
  • 落实河长制必须持之以恒 2019-06-22
  • 跟青岛人逛海边,聊上合 2019-06-18
  • 望远镜的眼睛有多大?这个参数很关键 2019-06-18
  • 人民日报召开创刊70周年读者座谈会 2019-06-09
  • 【改革印记——看中国发展】变迁印记,留下的是韵味现实 2019-05-31
  • [大笑]阿Q都是这么说的。。。。。。 2019-05-31
  • 曾祖红:天津欢乐谷二期将于6月30日对外开放 2019-05-28
  • 新发现:墨西哥发现恐龙新物种 2019-05-21
  • 为吸引中国游客 世界各国纷纷喊话:“我最懂你” 2019-05-21
  • 任天堂Switch九月开始收连线费 详细方案公开 2019-05-20
  • 独来独往代表什么生肖 陕西11选5开奖遗漏查询 排列五+软件 北京快三预测和值推荐 广东十一选五开奖信息 万达国际娱乐城官网地址 360导航彩票走势图 南国体彩 秒速飞艇规律 彩经网大乐透五分区走势图表 jr重庆时时彩 福建时时彩开奖列表 山西11选5中奖规则 3d3天计划论坛 广东快乐十分前三直遗漏