tag:blogger.com,1999:blog-3994600705300849450.post6551889515032852757..comments2023-11-02T05:01:46.205-07:00Comments on 程式設計工藝大師(Master of Computer Programming): 第七週許志宇(Chih-Yu Hsu)http://www.blogger.com/profile/10096107829485385586noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-3994600705300849450.post-71335031909823229912009-04-03T02:28:00.000-07:002009-04-03T02:28:00.000-07:00//應數三甲 徐晟哲 D9538864import java.util.*;public class...//應數三甲 徐晟哲 D9538864<BR/>import java.util.*;<BR/>public class Mytest{<BR/><BR/>public static void main(String[] args) {<BR/>UsingArrays usingArrays=new UsingArrays();<BR/>for(int j=0; j<=4; j++)<BR/>System.out.println(usingArrays.doubleValues[j]);<BR/><BR/>System.out.println("----");<BR/>Arrays.sort(usingArrays.doubleValues);<BR/>for(int i=0; i<=4; i++)<BR/>System.out.println(usingArrays.doubleValues[i]);<BR/><BR/>}<BR/>}DR.Hydrahttps://www.blogger.com/profile/04983338493331657192noreply@blogger.comtag:blogger.com,1999:blog-3994600705300849450.post-30867995295851817912009-04-03T02:18:00.000-07:002009-04-03T02:18:00.000-07:00D9788173光電一王則元import java.util.Arrays;class Mytest...D9788173光電一王則元<BR/><BR/>import java.util.Arrays;<BR/><BR/>class Mytest<BR/>{<BR/>static int[] array;<BR/> public static void main (String [] args)<BR/>{<BR/>int num = 15;<BR/>//int i = usingarrays.doubleValues;<BR/>array = new int[num+1];<BR/>for(int j=0; j<=num ; j++)<BR/>{<BR/>array[j]=j;<BR/>//System.out.println(array[j]);<BR/>}<BR/><BR/><BR/>UsingArrays usingarrays =new UsingArrays();<BR/>//System.out.println(usingarrays.intValues[0]);<BR/><BR/>for(int i=0; i<=4 ; i++) {<BR/><BR/>System.out.println(usingarrays.doubleValues[i]);<BR/>}<BR/><BR/> for(int i=0; i<=4 ; i++) {<BR/> Arrays.sort( usingarrays.doubleValues );<BR/> System.out.println(usingarrays.doubleValues[i]);<BR/> }<BR/>}<BR/><BR/><BR/><BR/>}王則元https://www.blogger.com/profile/04083235685828450258noreply@blogger.comtag:blogger.com,1999:blog-3994600705300849450.post-55438866952616856792009-04-03T02:10:00.000-07:002009-04-03T02:10:00.000-07:00import java.util.*; public class UsingArrays { ...import java.util.*; <BR/><BR/>public class UsingArrays { <BR/> public int intValues[] = { 1, 2, 3, 4, 5, 6 }; <BR/> public double doubleValues[] = { 8.4, 9.3, 0.2, 7.9, 3.4 }; <BR/> private int filledInt[], intValuesCopy[]; <BR/><BR/> public UsingArrays() <BR/> { <BR/> filledInt = new int[ 10 ]; <BR/> intValuesCopy = new int[ intValues.length ]; <BR/> Arrays.fill( filledInt, 7 ); // fill with 7s <BR/> // Arrays.sort( doubleValues ); // sort doubleValues <BR/> System.arraycopy( intValues, 0, intValuesCopy, 0, intValues.length ); <BR/> } <BR/><BR/> public void printArrays() <BR/> { <BR/> System.out.print( "doubleValues: " ); <BR/> for ( int k = 0; k < doubleValues.length; k++ ) <BR/> System.out.print( doubleValues[ k ] + " " ); <BR/><BR/> System.out.print("\nintValues: " ); <BR/> for ( int k = 0; k < intValues.length; k++ ) <BR/> System.out.print( intValues[ k ] + " " ); <BR/><BR/> System.out.print("\nfilledInt: " ); <BR/> for ( int k = 0; k < filledInt.length; k++ ) <BR/> System.out.print( filledInt[ k ] + " " ); <BR/><BR/> System.out.print("\nintValuesCopy: " ); <BR/> for ( int k = 0; k < intValuesCopy.length; k++ ) <BR/> System.out.print( intValuesCopy[ k ] + " " ); <BR/><BR/> System.out.println(); <BR/> } <BR/><BR/> public int searchForInt( int value ) <BR/> { return Arrays.binarySearch( intValues, value ); } <BR/><BR/> public void printEquality() <BR/> { <BR/> boolean b = Arrays.equals( intValues, intValuesCopy ); <BR/><BR/> System.out.println( "intValues " + ( b ? "==" : "!=" ) + " intValuesCopy" ); <BR/><BR/> b = Arrays.equals( intValues, filledInt ); <BR/> System.out.println( "intValues " + ( b ? "==" : "!=" ) + " filledInt" ); <BR/> } <BR/><BR/> public static void main( String args[] ) <BR/> { <BR/> UsingArrays u = new UsingArrays(); <BR/><BR/> u.printArrays(); <BR/> u.printEquality(); <BR/><BR/> int n = u.searchForInt( 5 ); <BR/> System.out.println( ( n >= 0 ? "Found 5 at element " + n : "5 not found" ) + " in intValues" ); <BR/> n = u.searchForInt( 8763 ); <BR/> System.out.println( ( n >= 0 ? "Found 8763 at element " <BR/> + n : "8763 not found" ) <BR/> + " in intValues" ); <BR/> } <BR/>} <BR/><BR/><BR/>//2<BR/><BR/>import java.util.*; <BR/><BR/>class Mytest {<BR/><BR/>public static void main(String[] args)<BR/>{ <BR/>UsingArrays usingArrays=new UsingArrays();<BR/>for(int i=0;i<5;i++)<BR/>System.out.println(usingArrays.doubleValues[i]);<BR/>System.out.println("...");<BR/>Arrays.sort(usingArrays.doubleValues);<BR/>for(int j=0;j<5;j++)<BR/>System.out.println(usingArrays.doubleValues[j]);<BR/><BR/>}<BR/>}益銘梁https://www.blogger.com/profile/08658774514868410414noreply@blogger.comtag:blogger.com,1999:blog-3994600705300849450.post-89573614879969434012009-04-03T02:05:00.001-07:002009-04-03T02:05:00.001-07:00D9377831 劉羽程----------------------------------impo...D9377831 劉羽程<BR/>----------------------------------<BR/>import java.util.*;<BR/>class Mytest{<BR/><BR/>static int[] array;<BR/><BR/>public static void main(String[] args) {<BR/>int num = 4;<BR/>array = new int[num+1];<BR/><BR/>for(int j=0; j<=num ; j++) {<BR/>array[j]=j;<BR/>//System.out.println(array[j]);<BR/>UsingArrays usingarrays = new UsingArrays();<BR/>//System.out.println(usingarrays.intValues[0]);<BR/>Arrays.sort(usingarrays.doubleValues);<BR/>System.out.println(usingarrays.doubleValues[j]);<BR/><BR/>}<BR/>}<BR/>}<BR/>-----------------------------------<BR/><BR/>// Fig. 21.1: UsingArrays.java<BR/>// Using Java arrays.<BR/><BR/>// Java core packages<BR/>import java.util.*;<BR/><BR/>public class UsingArrays {<BR/>public int intValues[] = { 1, 2, 3, 4, 5, 6 };<BR/>public double doubleValues[] = { 8.4, 9.3, 0.2, 7.9, 3.4 };<BR/>public int filledInt[], intValuesCopy[];<BR/><BR/>// initialize arrays<BR/>public UsingArrays()<BR/>{<BR/>filledInt = new int[ 10 ];<BR/>intValuesCopy = new int[ intValues.length ];<BR/><BR/>Arrays.fill( filledInt, 7 ); // fill with 7s<BR/><BR/>//Arrays.sort( doubleValues ); // sort doubleValues<BR/><BR/>System.arraycopy( intValues, 0, intValuesCopy,<BR/>0, intValues.length );<BR/>}<BR/><BR/>// output values in each array<BR/>public void printArrays()<BR/>{ <BR/>System.out.print( "doubleValues: " );<BR/><BR/>for ( int count = 0; count < doubleValues.length; count++ )<BR/>System.out.print( doubleValues[ count ] + " " );<BR/><BR/>System.out.print( "\nintValues: " );<BR/><BR/>for ( int count = 0; count < intValues.length; count++ )<BR/>System.out.print( intValues[ count ] + " " );<BR/><BR/>System.out.print( "\nfilledInt: " );<BR/><BR/>for ( int count = 0; count < filledInt.length; count++ )<BR/>System.out.print( filledInt[ count ] + " " );<BR/><BR/>System.out.print( "\nintValuesCopy: " );<BR/><BR/>for ( int count = 0; count < intValuesCopy.length; count++ )<BR/>System.out.print( intValuesCopy[ count ] + " " );<BR/><BR/>System.out.println();<BR/>}<BR/><BR/>// find value in array intValues<BR/>public int searchForInt( int value )<BR/>{ <BR/>return Arrays.binarySearch( intValues, value );<BR/>}<BR/><BR/>// compare array contents<BR/>public void printEquality()<BR/>{<BR/>boolean b = Arrays.equals( intValues, intValuesCopy );<BR/><BR/>System.out.println( "intValues " + ( b ? "==" : "!=" )<BR/>+ " intValuesCopy" );<BR/><BR/>b = Arrays.equals( intValues, filledInt );<BR/><BR/>System.out.println( "intValues " + ( b ? "==" : "!=" )<BR/>+ " filledInt" );<BR/>}<BR/><BR/>// execute application<BR/>public static void main( String args[] )<BR/>{<BR/>UsingArrays usingArrays = new UsingArrays();<BR/><BR/>usingArrays.printArrays();<BR/>usingArrays.printEquality();<BR/><BR/>int location = usingArrays.searchForInt( 5 );<BR/>System.out.println( ( location >= 0 ? <BR/>"Found 5 at element " + location : "5 not found" ) + <BR/>" in intValues" );<BR/><BR/>location = usingArrays.searchForInt( 8763 );<BR/>System.out.println( ( location >= 0 ? <BR/>"Found 8763 at element " + location : <BR/>"8763 not found" ) + " in intValues" ); <BR/>} <BR/><BR/>} // end class UsingArrays<BR/><BR/>/**************************************************************************<BR/>* (C) Copyright 2002 by Deitel & Associates, Inc. and Prentice Hall. *<BR/>* All Rights Reserved. *<BR/>* *<BR/>* DISCLAIMER: The authors and publisher of this book have used their *<BR/>* best efforts in preparing the book. These efforts include the *<BR/>* development, research, and testing of the theories and programs *<BR/>* to determine their effectiveness. The authors and publisher make *<BR/>* no warranty of any kind, expressed or implied, with regard to these *<BR/>* programs or to the documentation contained in these books. The authors *<BR/>* and publisher shall not be liable in any event for incidental or *<BR/>* consequential damages in connection with, or arising out of, the *<BR/>* furnishing, performance, or use of these programs. *<BR/>*************************************************************************/程https://www.blogger.com/profile/14142949769979347640noreply@blogger.comtag:blogger.com,1999:blog-3994600705300849450.post-5764118650954512542009-04-03T02:05:00.000-07:002009-04-03T02:05:00.000-07:00//第七週 d9476668陳秋宇// Fig. 21.1: UsingArrays.java// ...//第七週 d9476668陳秋宇<BR/><BR/>// Fig. 21.1: UsingArrays.java<BR/>// Using Java arrays.<BR/><BR/>// Java core packages<BR/>import java.util.*;<BR/><BR/>public class UsingArrays {<BR/> public int intValues[] = { 1, 2, 3, 4, 5, 6 };<BR/> public double doubleValues[] = { 8.4, 9.3, 0.2, 7.9, 3.4 };<BR/> private int filledInt[], intValuesCopy[];<BR/><BR/> // initialize arrays<BR/> public UsingArrays()<BR/> {<BR/> filledInt = new int[ 10 ];<BR/> intValuesCopy = new int[ intValues.length ];<BR/><BR/> Arrays.fill( filledInt, 7 ); // fill with 7s<BR/><BR/> //Arrays.sort( doubleValues ); // sort doubleValues<BR/><BR/> System.arraycopy( intValues, 0, intValuesCopy,<BR/> 0, intValues.length );<BR/> }<BR/><BR/> // output values in each array<BR/> public void printArrays()<BR/> { <BR/> System.out.print( "doubleValues: " );<BR/><BR/> for ( int count = 0; count < doubleValues.length; count++ )<BR/> System.out.print( doubleValues[ count ] + " " );<BR/><BR/> System.out.print( "\nintValues: " );<BR/><BR/> for ( int count = 0; count < intValues.length; count++ )<BR/> System.out.print( intValues[ count ] + " " );<BR/><BR/> System.out.print( "\nfilledInt: " );<BR/><BR/> for ( int count = 0; count < filledInt.length; count++ )<BR/> System.out.print( filledInt[ count ] + " " );<BR/><BR/> System.out.print( "\nintValuesCopy: " );<BR/><BR/> for ( int count = 0; count < intValuesCopy.length; count++ )<BR/> System.out.print( intValuesCopy[ count ] + " " );<BR/><BR/> System.out.println();<BR/> }<BR/><BR/> // find value in array intValues<BR/> public int searchForInt( int value )<BR/> { <BR/> return Arrays.binarySearch( intValues, value );<BR/> }<BR/><BR/> // compare array contents<BR/> public void printEquality()<BR/> {<BR/> boolean b = Arrays.equals( intValues, intValuesCopy );<BR/><BR/> System.out.println( "intValues " + ( b ? "==" : "!=" )<BR/> + " intValuesCopy" );<BR/><BR/> b = Arrays.equals( intValues, filledInt );<BR/><BR/> System.out.println( "intValues " + ( b ? "==" : "!=" )<BR/> + " filledInt" );<BR/> }<BR/><BR/> // execute application<BR/> public static void main( String args[] )<BR/> {<BR/> UsingArrays usingArrays = new UsingArrays();<BR/><BR/> usingArrays.printArrays();<BR/> usingArrays.printEquality();<BR/><BR/> int location = usingArrays.searchForInt( 5 );<BR/> System.out.println( ( location >= 0 ? <BR/> "Found 5 at element " + location : "5 not found" ) + <BR/> " in intValues" );<BR/><BR/> location = usingArrays.searchForInt( 8763 );<BR/> System.out.println( ( location >= 0 ? <BR/> "Found 8763 at element " + location : <BR/> "8763 not found" ) + " in intValues" ); <BR/> } <BR/> <BR/>} // end class UsingArrays<BR/><BR/>/**************************************************************************<BR/> * (C) Copyright 2002 by Deitel & Associates, Inc. and Prentice Hall. *<BR/> * All Rights Reserved. *<BR/> * *<BR/> * DISCLAIMER: The authors and publisher of this book have used their *<BR/> * best efforts in preparing the book. These efforts include the *<BR/> * development, research, and testing of the theories and programs *<BR/> * to determine their effectiveness. The authors and publisher make *<BR/> * no warranty of any kind, expressed or implied, with regard to these *<BR/> * programs or to the documentation contained in these books. The authors *<BR/> * and publisher shall not be liable in any event for incidental or *<BR/> * consequential damages in connection with, or arising out of, the *<BR/> * furnishing, performance, or use of these programs. *<BR/> *************************************************************************/<BR/>import java.util.Arrays;<BR/>class Mytestjava<BR/>{<BR/>static int[] array;<BR/>public static void main(String[] args)<BR/>{<BR/>int num=5;<BR/>array = new int[num+1];<BR/>for(int j=0; j<=num ; j++)<BR/>{<BR/>array[j]=j;<BR/>//System.out.println(array[j]);<BR/>}<BR/><BR/>UsingArrays usingArrays = new UsingArrays();<BR/>for(int j=0; j<=4 ; j++)<BR/>{<BR/>System.out.println(usingArrays.doubleValues[j]);<BR/>}<BR/><BR/><BR/>Arrays.sort(usingArrays.doubleValues); <BR/>for(int j=0; j<=4 ; j++)<BR/>{<BR/>System.out.println(usingArrays.doubleValues[j]);<BR/><BR/>}<BR/>}<BR/>}Unknownhttps://www.blogger.com/profile/05523244086537760271noreply@blogger.comtag:blogger.com,1999:blog-3994600705300849450.post-33812262765568530232009-04-03T01:59:00.000-07:002009-04-03T01:59:00.000-07:00//D9476995 應數四乙 辛為儒import java.util.Arrays;class M...//D9476995 應數四乙 辛為儒<BR/>import java.util.Arrays;<BR/><BR/>class Mytest<BR/>{<BR/> static int[] array;<BR/>public static void main( String args[] )<BR/>{<BR/> int num = 3;<BR/> int k = 0;<BR/> array = new int[num+1];<BR/> for (int j = 1; j <= num; j++)<BR/> {<BR/> array[j] = j;<BR/> //System.out.println(array[j]);<BR/> }<BR/> UsingArrays usingArrays = new UsingArrays();<BR/> System.out.println(usingArrays.intValues[0]);<BR/> Arrays.sort(usingArrays.doubleValues);<BR/> <BR/> for (k = 0; k < 5; k++)<BR/> {<BR/><BR/> System.out.println(usingArrays.doubleValues[k]);<BR/><BR/> }<BR/><BR/>}<BR/>}儒https://www.blogger.com/profile/14660857513968548993noreply@blogger.comtag:blogger.com,1999:blog-3994600705300849450.post-58805659733860147352009-04-03T01:58:00.000-07:002009-04-03T01:58:00.000-07:00第七週作業 D9582256 高岱群// Fig. 21.1: UsingArrays.java//...第七週作業 D9582256 高岱群<BR/>// Fig. 21.1: UsingArrays.java<BR/>// Using Java arrays.<BR/><BR/>// Java core packages<BR/>import java.util.*;<BR/><BR/>public class UsingArrays {<BR/> public int intValues[] = { 1, 2, 3, 4, 5, 6 };<BR/> public double doubleValues[] = { 8.4, 9.3, 0.2, 7.9, 3.4 };<BR/> private int filledInt[], intValuesCopy[];<BR/><BR/> // initialize arrays<BR/> public UsingArrays()<BR/> {<BR/> filledInt = new int[ 10 ];<BR/> intValuesCopy = new int[ intValues.length ];<BR/><BR/> Arrays.fill( filledInt, 7 ); // fill with 7s<BR/><BR/> //Arrays.sort( doubleValues ); // sort doubleValues<BR/><BR/> System.arraycopy( intValues, 0, intValuesCopy,<BR/> 0, intValues.length );<BR/> }<BR/><BR/> // output values in each array<BR/> public void printArrays()<BR/> { <BR/> System.out.print( "doubleValues: " );<BR/><BR/> for ( int count = 0; count < doubleValues.length; count++ )<BR/> System.out.print( doubleValues[ count ] + " " );<BR/><BR/> System.out.print( "\nintValues: " );<BR/><BR/> for ( int count = 0; count < intValues.length; count++ )<BR/> System.out.print( intValues[ count ] + " " );<BR/><BR/> System.out.print( "\nfilledInt: " );<BR/><BR/> for ( int count = 0; count < filledInt.length; count++ )<BR/> System.out.print( filledInt[ count ] + " " );<BR/><BR/> System.out.print( "\nintValuesCopy: " );<BR/><BR/> for ( int count = 0; count < intValuesCopy.length; count++ )<BR/> System.out.print( intValuesCopy[ count ] + " " );<BR/><BR/> System.out.println();<BR/> }<BR/><BR/> // find value in array intValues<BR/> public int searchForInt( int value )<BR/> { <BR/> return Arrays.binarySearch( intValues, value );<BR/> }<BR/><BR/> // compare array contents<BR/> public void printEquality()<BR/> {<BR/> boolean b = Arrays.equals( intValues, intValuesCopy );<BR/><BR/> System.out.println( "intValues " + ( b ? "==" : "!=" )<BR/> + " intValuesCopy" );<BR/><BR/> b = Arrays.equals( intValues, filledInt );<BR/><BR/> System.out.println( "intValues " + ( b ? "==" : "!=" )<BR/> + " filledInt" );<BR/> }<BR/><BR/> // execute application<BR/> public static void main( String args[] )<BR/> {<BR/> UsingArrays usingArrays = new UsingArrays();<BR/><BR/> usingArrays.printArrays();<BR/> usingArrays.printEquality();<BR/><BR/> int location = usingArrays.searchForInt( 5 );<BR/> System.out.println( ( location >= 0 ? <BR/> "Found 5 at element " + location : "5 not found" ) + <BR/> " in intValues" );<BR/><BR/> location = usingArrays.searchForInt( 8763 );<BR/> System.out.println( ( location >= 0 ? <BR/> "Found 8763 at element " + location : <BR/> "8763 not found" ) + " in intValues" ); <BR/> } <BR/> <BR/>} // end class UsingArrays<BR/><BR/>-----------------------------------<BR/><BR/>import java.util.Arrays;<BR/>class Ratext<BR/>{<BR/>static int[] array;<BR/>public static void main( String args[] )<BR/>{<BR/>UsingArrays usingArrays = new UsingArrays();<BR/>for(int j=0; j<=4 ; j++)<BR/>{<BR/>System.out.println(usingArrays.doubleValues[j]);<BR/>}<BR/>Arrays.sort(usingArrays.doubleValues); <BR/>for(int j=0; j<=4 ; j++)<BR/>{<BR/>System.out.println(usingArrays.doubleValues[j]);<BR/>}<BR/>}<BR/>}radropshttps://www.blogger.com/profile/18114610781414771700noreply@blogger.comtag:blogger.com,1999:blog-3994600705300849450.post-80059598362177114812009-04-03T01:53:00.000-07:002009-04-03T01:53:00.000-07:00/*第七週 d9582608 廖仁龍*/import java.util.*;class dark8.../*第七週 d9582608 廖仁龍*/<BR/>import java.util.*;<BR/>class dark8<BR/>{<BR/>static int [] array;<BR/>public static void main(String []args)<BR/>{<BR/>int num = 5 ;<BR/>array = new int[num+1];<BR/>for (int j = 1; j <= num; j++)<BR/>{<BR/>array[j] = j;<BR/>System.out.println(array[j]);<BR/>}<BR/>UsingArrays usingArrays = new UsingArrays();<BR/>System.out.println(usingArrays.intValues[0]);<BR/>Arrays.sort(usingArrays.doubleValues);<BR/>System.out.println(usingArrays.doubleValues[0]);<BR/>System.out.println(usingArrays.doubleValues[1]);<BR/>System.out.println(usingArrays.doubleValues[2]);<BR/>System.out.println(usingArrays.doubleValues[3]);<BR/>System.out.println(usingArrays.doubleValues[4]);<BR/>}<BR/>}dragonhttps://www.blogger.com/profile/10698843650771029982noreply@blogger.comtag:blogger.com,1999:blog-3994600705300849450.post-5685149894935355062009-04-03T01:52:00.001-07:002009-04-03T01:52:00.001-07:00D9538905// Fig. 21.1: UsingArrays.java// Using Jav...D9538905<BR/><BR/>// Fig. 21.1: UsingArrays.java<BR/>// Using Java arrays.<BR/><BR/>// Java core packages<BR/>import java.util.*;<BR/><BR/>public class UsingArrays {<BR/> public int intValues[] = { 1, 2, 3, 4, 5, 6 };<BR/> public double doubleValues[] = { 8.4, 9.3, 0.2, 7.9, 3.4 };<BR/> private int filledInt[], intValuesCopy[];<BR/><BR/> // initialize arrays<BR/> public UsingArrays()<BR/> {<BR/> filledInt = new int[ 10 ];<BR/> intValuesCopy = new int[ intValues.length ];<BR/><BR/> Arrays.fill( filledInt, 7 ); // fill with 7s<BR/><BR/> //Arrays.sort( doubleValues ); // sort doubleValues<BR/><BR/> System.arraycopy( intValues, 0, intValuesCopy,<BR/> 0, intValues.length );<BR/> }<BR/><BR/> // output values in each array<BR/> public void printArrays()<BR/> { <BR/> System.out.print( "doubleValues: " );<BR/><BR/> for ( int count = 0; count < doubleValues.length; count++ )<BR/> System.out.print( doubleValues[ count ] + " " );<BR/><BR/> System.out.print( "\nintValues: " );<BR/><BR/> for ( int count = 0; count < intValues.length; count++ )<BR/> System.out.print( intValues[ count ] + " " );<BR/><BR/> System.out.print( "\nfilledInt: " );<BR/><BR/> for ( int count = 0; count < filledInt.length; count++ )<BR/> System.out.print( filledInt[ count ] + " " );<BR/><BR/> System.out.print( "\nintValuesCopy: " );<BR/><BR/> for ( int count = 0; count < intValuesCopy.length; count++ )<BR/> System.out.print( intValuesCopy[ count ] + " " );<BR/><BR/> System.out.println();<BR/> }<BR/><BR/> // find value in array intValues<BR/> public int searchForInt( int value )<BR/> { <BR/> return Arrays.binarySearch( intValues, value );<BR/> }<BR/><BR/> // compare array contents<BR/> public void printEquality()<BR/> {<BR/> boolean b = Arrays.equals( intValues, intValuesCopy );<BR/><BR/> System.out.println( "intValues " + ( b ? "==" : "!=" )<BR/> + " intValuesCopy" );<BR/><BR/> b = Arrays.equals( intValues, filledInt );<BR/><BR/> System.out.println( "intValues " + ( b ? "==" : "!=" )<BR/> + " filledInt" );<BR/> }<BR/><BR/> // execute application<BR/> public static void main( String args[] )<BR/> {<BR/> UsingArrays usingArrays = new UsingArrays();<BR/><BR/> usingArrays.printArrays();<BR/> usingArrays.printEquality();<BR/><BR/> int location = usingArrays.searchForInt( 5 );<BR/> System.out.println( ( location >= 0 ? <BR/> "Found 5 at element " + location : "5 not found" ) + <BR/> " in intValues" );<BR/><BR/> location = usingArrays.searchForInt( 8763 );<BR/> System.out.println( ( location >= 0 ? <BR/> "Found 8763 at element " + location : <BR/> "8763 not found" ) + " in intValues" ); <BR/> } <BR/> <BR/>} // end class UsingArrays<BR/><BR/>/**************************************************************************<BR/> * (C) Copyright 2002 by Deitel & Associates, Inc. and Prentice Hall. *<BR/> * All Rights Reserved. *<BR/> * *<BR/> * DISCLAIMER: The authors and publisher of this book have used their *<BR/> * best efforts in preparing the book. These efforts include the *<BR/> * development, research, and testing of the theories and programs *<BR/> * to determine their effectiveness. The authors and publisher make *<BR/> * no warranty of any kind, expressed or implied, with regard to these *<BR/> * programs or to the documentation contained in these books. The authors *<BR/> * and publisher shall not be liable in any event for incidental or *<BR/> * consequential damages in connection with, or arising out of, the *<BR/> * furnishing, performance, or use of these programs. *<BR/> *************************************************************************/<BR/><BR/><BR/>import java.util.*;<BR/><BR/>class Mytest<BR/>{<BR/>static int[] array;<BR/><BR/>public static void main(String[] args)<BR/>{<BR/>int num = 15;<BR/>array = new int[num+1];<BR/>for(int j=1; j<=num ; j++)<BR/>{<BR/>array[j]=j;<BR/>//System.out.println(array[j]);<BR/>}<BR/>UsingArrays usingArrays=new UsingArrays();<BR/>//System.out.println(usingArrays.intValues[0]);<BR/>Arrays.sort( usingArrays.doubleValues );<BR/>for(int j=0; j<=4 ; j++){<BR/>System.out.println(usingArrays.doubleValues[j]);<BR/>}<BR/>}<BR/>}d9538905https://www.blogger.com/profile/05852240367880649967noreply@blogger.comtag:blogger.com,1999:blog-3994600705300849450.post-77513541295065270902009-04-03T01:52:00.000-07:002009-04-03T01:52:00.000-07:00/*D9539108 陸靖文*/import java.util.*;class FB04 { .../*D9539108 陸靖文*/<BR/>import java.util.*;<BR/><BR/>class FB04 {<BR/><BR/> static int[] array;<BR/> <BR/> public static void main(String[] args) {<BR/> int num = 4;<BR/> array = new int[num+1];<BR/> for(int j=0; j<=num ; j++) {<BR/> array[j]=j;<BR/><BR/> UsingArrays usingarrays = new UsingArrays();<BR/> Arrays.sort(usingarrays.doubleValues);<BR/> System.out.println(usingarrays.doubleValues[j]);<BR/><BR/> //System.out.println(array[j]);<BR/> }<BR/> }<BR/><BR/>}<BR/><BR/>//-------------------------------<BR/>// Fig. 21.1: UsingArrays.java<BR/>// Using Java arrays.<BR/><BR/>// Java core packages<BR/>import java.util.*;<BR/><BR/>public class UsingArrays {<BR/> public int intValues[] = { 1, 2, 3, 4, 5, 6 };<BR/> public double doubleValues[] = { 8.4, 9.3, 0.2, 7.9, 3.4 };<BR/> public int filledInt[], intValuesCopy[];<BR/><BR/> // initialize arrays<BR/> public UsingArrays()<BR/> {<BR/> filledInt = new int[ 10 ];<BR/> intValuesCopy = new int[ intValues.length ];<BR/><BR/> Arrays.fill( filledInt, 7 ); // fill with 7s<BR/><BR/> //Arrays.sort( doubleValues ); // sort doubleValues<BR/><BR/> System.arraycopy( intValues, 0, intValuesCopy,<BR/> 0, intValues.length );<BR/> }<BR/><BR/> // output values in each array<BR/> public void printArrays()<BR/> { <BR/> System.out.print( "doubleValues: " );<BR/><BR/> for ( int count = 0; count < doubleValues.length; count++ )<BR/> System.out.print( doubleValues[ count ] + " " );<BR/><BR/> System.out.print( "\nintValues: " );<BR/><BR/> for ( int count = 0; count < intValues.length; count++ )<BR/> System.out.print( intValues[ count ] + " " );<BR/><BR/> System.out.print( "\nfilledInt: " );<BR/><BR/> for ( int count = 0; count < filledInt.length; count++ )<BR/> System.out.print( filledInt[ count ] + " " );<BR/><BR/> System.out.print( "\nintValuesCopy: " );<BR/><BR/> for ( int count = 0; count < intValuesCopy.length; count++ )<BR/> System.out.print( intValuesCopy[ count ] + " " );<BR/><BR/> System.out.println();<BR/> }<BR/><BR/> // find value in array intValues<BR/> public int searchForInt( int value )<BR/> { <BR/> return Arrays.binarySearch( intValues, value );<BR/> }<BR/><BR/> // compare array contents<BR/> public void printEquality()<BR/> {<BR/> boolean b = Arrays.equals( intValues, intValuesCopy );<BR/><BR/> System.out.println( "intValues " + ( b ? "==" : "!=" )<BR/> + " intValuesCopy" );<BR/><BR/> b = Arrays.equals( intValues, filledInt );<BR/><BR/> System.out.println( "intValues " + ( b ? "==" : "!=" )<BR/> + " filledInt" );<BR/> }<BR/><BR/> // execute application<BR/> public static void main( String args[] )<BR/> {<BR/> UsingArrays usingArrays = new UsingArrays();<BR/><BR/> usingArrays.printArrays();<BR/> usingArrays.printEquality();<BR/><BR/> int location = usingArrays.searchForInt( 5 );<BR/> System.out.println( ( location >= 0 ? <BR/> "Found 5 at element " + location : "5 not found" ) + <BR/> " in intValues" );<BR/><BR/> location = usingArrays.searchForInt( 8763 );<BR/> System.out.println( ( location >= 0 ? <BR/> "Found 8763 at element " + location : <BR/> "8763 not found" ) + " in intValues" ); <BR/> } <BR/> <BR/>} // end class UsingArrays<BR/><BR/>/**************************************************************************<BR/> * (C) Copyright 2002 by Deitel & Associates, Inc. and Prentice Hall. *<BR/> * All Rights Reserved. *<BR/> * *<BR/> * DISCLAIMER: The authors and publisher of this book have used their *<BR/> * best efforts in preparing the book. These efforts include the *<BR/> * development, research, and testing of the theories and programs *<BR/> * to determine their effectiveness. The authors and publisher make *<BR/> * no warranty of any kind, expressed or implied, with regard to these *<BR/> * programs or to the documentation contained in these books. The authors *<BR/> * and publisher shall not be liable in any event for incidental or *<BR/> * consequential damages in connection with, or arising out of, the *<BR/> * furnishing, performance, or use of these programs. *<BR/> *************************************************************************/BBBhttps://www.blogger.com/profile/17083313806490533730noreply@blogger.comtag:blogger.com,1999:blog-3994600705300849450.post-45786958566468002042009-04-03T01:51:00.000-07:002009-04-03T01:51:00.000-07:00//第七週作業 D9539125 黃培熏//UsingArrays.class import jav...//第七週作業 D9539125 黃培熏<BR/>//UsingArrays.class <BR/>import java.util.*; <BR/><BR/>public class UsingArrays { <BR/> public int intValues[] = { 1, 2, 3, 4, 5, 6 }; <BR/> public double doubleValues[] = { 8.4, 9.3, 0.2, 7.9, 3.4 }; <BR/> private int filledInt[], intValuesCopy[]; <BR/><BR/> public UsingArrays() <BR/> { <BR/> filledInt = new int[ 10 ]; <BR/> intValuesCopy = new int[ intValues.length ]; <BR/> Arrays.fill( filledInt, 7 ); // fill with 7s <BR/> //Arrays.sort( doubleValues ); // sort doubleValues <BR/> System.arraycopy( intValues, 0, intValuesCopy, 0, intValues.length ); <BR/> } <BR/><BR/> public void printArrays() <BR/> { <BR/> System.out.print( "doubleValues: " ); <BR/> for ( int k = 0; k < doubleValues.length; k++ ) <BR/> System.out.print( doubleValues[ k ] + " " ); <BR/><BR/> System.out.print("\nintValues: " ); <BR/> for ( int k = 0; k < intValues.length; k++ ) <BR/> System.out.print( intValues[ k ] + " " ); <BR/><BR/> System.out.print("\nfilledInt: " ); <BR/> for ( int k = 0; k < filledInt.length; k++ ) <BR/> System.out.print( filledInt[ k ] + " " ); <BR/><BR/> System.out.print("\nintValuesCopy: " ); <BR/> for ( int k = 0; k < intValuesCopy.length; k++ ) <BR/> System.out.print( intValuesCopy[ k ] + " " ); <BR/><BR/> System.out.println(); <BR/> } <BR/><BR/> public int searchForInt( int value ) <BR/> { return Arrays.binarySearch( intValues, value ); } <BR/><BR/> public void printEquality() <BR/> { <BR/> boolean b = Arrays.equals( intValues, intValuesCopy ); <BR/><BR/> System.out.println( "intValues " + ( b ? "==" : "!=" ) + " intValuesCopy" ); <BR/><BR/> b = Arrays.equals( intValues, filledInt ); <BR/> System.out.println( "intValues " + ( b ? "==" : "!=" ) + " filledInt" ); <BR/> } <BR/><BR/> public static void main( String args[] ) <BR/> { <BR/> UsingArrays u = new UsingArrays(); <BR/><BR/> u.printArrays(); <BR/> u.printEquality(); <BR/><BR/> int n = u.searchForInt( 5 ); <BR/> System.out.println( ( n >= 0 ? "Found 5 at element " + n : "5 not found" ) + " in intValues" ); <BR/> n = u.searchForInt( 8763 ); <BR/> System.out.println( ( n >= 0 ? "Found 8763 at element " <BR/> + n : "8763 not found" ) <BR/> + " in intValues" ); <BR/> } <BR/>} <BR/><BR/>//HPS_007.class<BR/>import java.io.*;<BR/>import java.awt.*;<BR/>import javax.swing.*;<BR/>import java.util.*; <BR/>import java.util.StringTokenizer;<BR/><BR/>public class HPS_007 {<BR/>public static void main(String[] args)<BR/>{<BR/>UsingArrays use_array = new UsingArrays();<BR/>Arrays.sort(use_array.doubleValues);<BR/>for (int i=0;i<5;i++)<BR/>System.out.println(use_array.doubleValues[i]);<BR/>}<BR/>}HPShttps://www.blogger.com/profile/06746558852621923053noreply@blogger.comtag:blogger.com,1999:blog-3994600705300849450.post-8787949195413212482009-04-03T01:49:00.000-07:002009-04-03T01:49:00.000-07:00作者已經移除這則留言。BBBhttps://www.blogger.com/profile/17083313806490533730noreply@blogger.com