herrDeng網內搜尋

自訂搜尋

Ads

2014年5月13日 星期二

Java作業10


  • 用random產生double陣列10個元素
  • 排序

36 則留言:

B10233061 吳興強 提到...

import java.util.Random;


public class ex1 {

public static void main(String[] args) {

double [] a= new double [10];
Random rnd = new Random();
for(int i=0; i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
for(int i=0;i<a.length-1;i++)
for (int j=0;j<a.length-1-i;j++){
if (a[j]>a[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

b10233080 陳芊慈 提到...

import java.util.Random;


public class aaa {

public static void main(String[] args) {
double [] a = new double [10];
Random rnd=new Random();
for(int i=0; i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
for(int i=0; i<a.length-1; i++)
for(int j=0 ;j<a.length-1-i; j++)
if(a[j]>a[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

b10233097 邱宥甄 提到...

import java.util.Random;


public class aaa {

public static void main(String[] args) {
double [] a = new double [10];
Random rnd=new Random();
for(int i=0; i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
for(int i=0; i<a.length-1; i++)
for(int j=0 ;j<a.length-1-i; j++)
if(a[j]>a[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

b0233098 陳孟緣 提到...

import java.util.Random;


public class aaa {

public static void main(String[] args) {
double [] a = new double [10];
Random rnd=new Random();
for(int i=0; i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
for(int i=0; i<a.length-1; i++)
for(int j=0 ;j<a.length-1-i; j++)
if(a[j]>a[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233064莊英霆 提到...

import java.util.Random;

public class lion {

public static void main(String[] args) {

double[] a=new double[10];
Random rnd =new Random();
for(int i=0; i<a.length;i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
for(int i=0;i<a.length-1;i++)
for(int j=0;j<a.length-1;j++){
if(a[j]>a[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233076 提到...

package hello;

import java.util.*;

public class ex2 {

public static void main(String[] args) {
double [] a= new double[10];
Random rnd=new Random();
for(int i=0; i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
Arrays.sort(a);
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233090 提到...

package hello0513;

import java.util.*;

public class Ex01 {

public static void main(String[] args) {
double [] a= new double[10];
Random rnd=new Random();
for(int i=0; i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
Arrays.sort(a);
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233110 提到...

package hey001;

import java.util.*;

public class hey123 {

public static void main(String[] args) {
double [] a= new double[10];
Random rnd=new Random();
for(int i=0; i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
Arrays.sort(a);
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233091許少威 提到...

package hello0513;

import java.util.*;

public class Ex01 {

public static void main(String[] args) {
double [] a= new double[10];
Random rnd=new Random();
for(int i=0; i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
Arrays.sort(a);
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233081 藍立凱 提到...

package helllo;

import java.util.*;

public class hello {

public static void main(String[] args) {
double [] a= new double[10];
Random rnd=new Random();
for(int i=0;i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
Arrays.sort(a);
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233084 陳億如 提到...

package hello0513;

import java.util.*;

public class Ex01 {

public static void main(String[] args) {
double [] a= new double[10];
Random rnd=new Random();
for(int i=0; i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
Arrays.sort(a);
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

Y10211027張君弘 提到...

package helen;

import java.util.*;

public class helen0513 {

public static void main(String[] args) {
double [] a=new double[10];
Random rnd=new Random();
for (int i = 0; i < a.length; i++) {
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
for (int i = 0; i < a.length-1; i++)
for (int j = 0; j < a.length-1; j++)
if(a[j]>a[(int) (j+1)]){
double tmp=a[j];
a[j]=a[(j+1)];
a[(j+1)]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233075 提到...

package hello0513;

import java.util.*;

public class hello {

public static void main(String[] args) {
double [] a= new double[10];
Random rnd=new Random();
for(int i=0; i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
Arrays.sort(a);
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233063 張宜禎 提到...

package hello0513;

import java.util.*;

public class ex1 {

public static void main(String[] args) {
double [] a= new double[10];
Random rnd=new Random();
for(int i=0; i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
Arrays.sort(a);
for(double i:a)
System.out.print(i+"\t");
System.out.println();

}

}

B10233103 提到...

package hello;

import java.util.Random;

public class hello {

public static void main(String[] args) {
// TODO Auto-generated method stub
double [] a=new double[10];
Random rnd=new Random();
for (double i = 0; i < a.length; i++) {
a[(int) i]=rnd.nextInt(100);
System.out.print(a[(int) i]+"\t");
}
System.out.println();
int j = 0;
for (double i = 0; j < a.length-1; j++)
if(a[(int) j]>a[(int)(j+1)]){
double tmp=a[(int) j];
a[(int) j]=a[(int) (j+1)];
a[(int) (j+1)]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

B10233109 提到...

package hello;

import java.util.Random;

public class hello {

public static void main(String[] args) {
// TODO Auto-generated method stub
double [] a=new double[10];
Random rnd=new Random();
for (double i = 0; i < a.length; i++) {
a[(int) i]=rnd.nextInt(100);
System.out.print(a[(int) i]+"\t");
}
System.out.println();
int j = 0;
for (double i = 0; j < a.length-1; j++)
if(a[(int) j]>a[(int)(j+1)]){
double tmp=a[(int) j];
a[(int) j]=a[(int) (j+1)];
a[(int) (j+1)]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

B10233102 提到...

package hello;

import java.util.Random;

public class hello {

public static void main(String[] args) {
// TODO Auto-generated method stub
double [] a=new double[10];
Random rnd=new Random();
for (double i = 0; i < a.length; i++) {
a[(int) i]=rnd.nextInt(100);
System.out.print(a[(int) i]+"\t");
}
System.out.println();
int j = 0;
for (double i = 0; j < a.length-1; j++)
if(a[(int) j]>a[(int)(j+1)]){
double tmp=a[(int) j];
a[(int) j]=a[(int) (j+1)];
a[(int) (j+1)]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

b9834164 陳彥翰 提到...

public static void main(String[] args) {
// TODO Auto-generated method stub
double [] a=new double[10];
Random rnd=new Random();
for(int i=0 ; ia[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();

}

}

B10233079 提到...

package hello;

import java.util.Random;

public class hello {

public static void main(String[] args) {
// TODO Auto-generated method stub
double [] a=new double[10];
Random rnd=new Random();
for (double i = 0; i < a.length; i++) {
a[(int) i]=rnd.nextInt(100);
System.out.print(a[(int) i]+"\t");
}
System.out.println();
int j = 0;
for (double i = 0; j < a.length-1; j++)
if(a[(int) j]>a[(int)(j+1)]){
double tmp=a[(int) j];
a[(int) j]=a[(int) (j+1)];
a[(int) (j+1)]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

B10233069連于傑 提到...

package hello513;

import java.util.Arrays;
import java.util.Random;

public class Ex1 {

public static void main(String[] args) {
Double[]a=new Double[10];
Random rnd=new Random();
for(int i=0;i<a.length;i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
Arrays.sort(a);
for(Double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

B10233089 提到...

package hello513;
import java.util.Random;
public class Ex1 {
public static void main(String[] args) {
double [ ] a=new double[10];
Random rnd=new Random();
for (int i=0;i<a.length;i++){
a[i]=rnd.nextDouble();
System.out.print(a[ i ]+" \t ");
}
System.out.println();
for (int i=0;i<a.length-1 ; i++)
for (int j=0;j<a.length-1-i ; j++)
if(a[ j ]>a[ j+1 ]){
double tmp=a[ j ];
a[ j ]=a[ j+1 ];
a[ j+1 ]= tmp;
}
for(double i:a)
System.out.print(i+" \t ");
System.out.println();
}
}

B10233067 提到...

package hello0513;
import java.util.Random;
public class ex1 {
public static void main(String[] args) {
double [] a=new double[10];
Random rnd=new Random();
for(int i=0;i<a.length;i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
for(int i=0;i<a.length-1;i++)
for(int j=0;j<a.length-1-i;j++)
if(a[j]>a[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233065 提到...

package hello0513;

import java.util.Arrays;
import java.util.Random;

public class hello {

public static void main(String[] args) {
Double[]a=new Double[10];
Random rnd=new Random();
for(int i=0;i<a.length;i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
Arrays.sort(a);
for(Double i:a)
System.out.print(i+"\t");
System.out.println();


}

}

B10233108 林宣瑋 提到...

package laolin;

import java.util.Random;

public class laolin0513 {

public static void main(String[] args) {
double [] a = new double[10];
Random rnd = new Random();
for(int i=0;i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
for(int i=0;i<a.length-1; i++)
for(int j=0;j<a.length-1-i; j++)
if(a[j]>a[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233066張哲毓 提到...

package dog0857;

import java.util.Random;

public class dog0857 {

public static void main(String[] args) {
double [] a = new double[10];
Random rnd = new Random();
for(int i=0;i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
for(int i=0;i<a.length-1; i++)
for(int j=0;j<a.length-1-i; j++)
if(a[j]>a[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

b10233068 . 邱佳函 提到...

package hello0513;

import java.util.*;

public class Ex01 {

public static void main(String[] args) {
double [] a= new double[10];
Random rnd=new Random();
for(int i=0; i<a.length; i++){
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
Arrays.sort(a);
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233062 黃聖評 提到...

package she;

import java.util.Random;
public class she1 {

public static void main(String[] args) {
double [] a=new double[10];
Random rnd=new Random();
for(int i=0;ia[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

B10233082唐偉強 提到...

import java.util.Random;
import java.util.Arrays;

public class asasa {


public static void main(String[] args) {
double [] a =new double[10];
Random rnd=new Random();
for(int i=0;i<a.length;i++){
a[i]=rnd.nextDouble()*100;
System.out.print(a[i]+"\t");
}
System.out.println();
Arrays.sort(a);

for(double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

B10233095李元宏 提到...

import java.util.Random;


public class ex1 {

public static void main(String[] args) {

double [] a= new double [10];
Random rnd = new Random();
for(int i=0; ia[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

B10233096 提到...

import java.util.Random;


public class aaa {

public static void main(String[] args) {
double [] a = new double [10];
Random rnd=new Random();
for(int i=0; ia[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233066張哲毓 提到...

package hihihi;

import java.util.Random;

public class hi0513 {

public static void main(String[] args) {
double [] a = new double[10];
Random rnd = new Random();
for(int i=0;ia[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233092 提到...

import java.util.Random;


public class ex1 {

public static void main(String[] args) {

double [] a= new double [10];
Random rnd = new Random();
for(int i=0; ia[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

B10233070劉思涵 提到...

mport java.util.Random;


public class ex1 {

public static void main(String[] args) {

double [] a= new double [10];
Random rnd = new Random();
for(int i=0; ia[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

B10233070劉思涵 提到...

mport java.util.Random;


public class ex1 {

public static void main(String[] args) {

double [] a= new double [10];
Random rnd = new Random();
for(int i=0; ia[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

B10233073 楊博宇 提到...

package roger2;

import java.util.*;

public class roger665 {

public static void main(String[] args) {
double [] a=new double[10];
Random rnd=new Random();
for (int i = 0; i < a.length; i++) {
a[i]=rnd.nextDouble();
System.out.print(a[i]+"\t");
}
System.out.println();
for (int i = 0; i < a.length-1; i++)
for (int j = 0; j < a.length-1; j++)
if(a[j]>a[(int) (j+1)]){
double tmp=a[j];
a[j]=a[(j+1)];
a[(j+1)]=tmp;
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}
}

B10233074 許逸憲 提到...

import java.util.Random;


public class ex11 {

public static void main(String[] args) {

double [] a= new double [10];
Random rnd = new Random();
for(int i=0; ia[j+1]){
double tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
for(double i:a)
System.out.print(i+"\t");
System.out.println();
}

}

Related Posts Plugin for WordPress, Blogger...

熱門文章