MIT Java Open Course Assignment #2

Source: Internet
Author: User

 Packagecome; Public classMarothon { Public Static voidFirstName (string[] ARGS1,int[] args2) {        intMinindex,mintime,i; Mintime= 10000; Minindex= 0;  for(i = 0; i < i++;){            if(Args2[i] <mintime) {Mintime=Args2[i]; Minindex=i; }} System.out.println (Args1[minindex]+ " "+mintime); }     Public Static voidSecondname (string[] ARGS1,int[] args2) {        intSmallindex,smallerindex,small,smaller,i; Small= 10000; Smaller= 10000; Smallerindex= 100; Smallindex=101;  for(i = 0; i<16; i++){            if(Args2[i] < Small && Args2[i] >Smaller) {Small=Args2[i]; Smallindex=i; }Else if(Args2[i] <Smaller) {Small=Smaller; Smaller=Args2[i]; Smallindex=Smallerindex; Smallerindex=i; }} System.out.println (Args1[smallindex]+ " " +Args2[smallindex]); }     Public Static voidMain (string[] args) {//TODO auto-generated Method StubString[] names = {"Elena", "Thomas", "Hamilton", "Suzie", "Phil", "Matt", "Alex",                "Emma", "John", "James", "Jane", "Emily", "Daniel", "Neda",                "Aaron", "Kate"}; int[] times = {341, 273, 278, 329, 445, 402, 388, 275, 243, 334, 412, 393, 299,                343, 317, 265}; Secondname (Names,times);}}
View Code

The Secondname function only iterates through the array once, greatly increasing the previous want to use FirstName traversal once with if to avoid the smallest to do, but will traverse two times, hahaha, good

MIT Java Open Course Assignment #2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.