sortarrary v1.0

Review Request #1888 — Created March 22, 2020 and updated

guest1942
imu
0
1024, 1025
demo
guest4789

sortarrary v1.0 is a sort for arrary.

package sortarrary;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class sort {
	private int geshu = 0;
	private int[] data = new int[100];

	public static int[] sortarray(int[] data) { // ???????????????????
		for (int i = 0; i < data.length; i++) {
			for (int j = 0; j < data.length - i - 1; j++) {
				if (data[j] > data[j + 1]) {
					swap(data, j, j + 1);
				}
			}
		}
		return data;
	}

	public static void swap(int[] data, int x, int y) {
		int temp = data[x];
		data[x] = data[y];
		data[y] = temp;
		// System.out.println(data[x]);
	}

	public static void print(int[] data, int geshu) {
		for (int i = 100 - geshu; i < 100; i++)
			System.out.print(data[i] + ",");

	}

	public static void main(String[] args) throws IOException {
		sort sort1 = new sort();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.println("????????");
		sort1.geshu = Integer.parseInt(br.readLine());
		for (int j = 0; j < sort1.geshu; j++)
			sort1.data[j] = 0;

		for (int i = 0; i < sort1.geshu; i++) {
			System.out.println("?????????" + (i + 1) + "???");
			sort1.data[i] = Integer.parseInt(br.readLine());
		}

		sort1.sortarray(sort1.data);
		sort1.print(sort1.data, sort1.geshu);
	}

}
Description From Last Updated

guest5295guest5295
guest1942
guest1942
guest4789
  1. ok

  2. 
      
guest1942
  1. Ship It!
  2. 
      
guest8829
  1. Test

  2. 
      
guest1942
Review request changed
guest5295
Loading...