トップ・ページの表示 注意書きの表示 掲示板に書き込む前に必ず この ”注意書き”を お読み下さい.

"沙羅"

★この掲示板は書き込みを停止いたしました 。
記事の書き込みはリンク・ページの表示 http://ashtarte.hotcom-web.com/utf8/smt.cgi?r+rpr/ を ご利用 下さい。

   
   

ページの表示順:{ 新しい順/ 古い順}.
初期・ページの表示・位置:{ 先頭ページ/ 末尾ページ}.
1ページ内のスレッド表示数:







<Number>: [00000399]  <Date>: 2020/09/25 22:58:03
<Title>: Javaデモ/バブルソート
<Name>: amanojaku@管理人

import java.util.Scanner;

public class J252 {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    System.out.println("テストの受験者数を入力して下さい");
    int viQuantity = scan.nextInt();
    int[] a1iStore = new int[viQuantity];
    for (int i = 0; i < a1iStore.length; i++) {
      System.out.println((i + 1) + "番目の点数を入力してください");
      a1iStore[i] = scan.nextInt();
    }
    System.out.println("昇順:1 降順:2");
    int viDirection = scan.nextInt();
    // Collections.sort(cal1Index, (i1, i2) -> a1iKyoukaSum[i2]-a1iKyoukaSum[i1]);
    // バブルソート:下記サイトのコードを修正しています
    // https://techacademy.jp/magazine/19444
    for (int i = 0; i < a1iStore.length - 1; i++) {
      for (int j = a1iStore.length - 1; j > i; j--) {
        int j0, jm1, cmp;
        j0 = a1iStore[j];
        jm1 = a1iStore[j - 1];
        cmp = jm1-j0;
        if (viDirection == 2) {
          cmp = -cmp;
        }
        if (0<cmp) {
          a1iStore[j - 1] = j0;
          a1iStore[j] = jm1;
        }
      }
    }
    if (viDirection != 2) {
      System.out.println("** 得点順(昇順) **");
    } else {
      System.out.println("** 得点順(降順) **");
    }
    for (int i = 0; i < a1iStore.length; i++) {
      System.out.println(a1iStore[i]+"点");
    }
  }
}

Block( Address 0000039A Identity 00000399 )






ページの表示順:{ 新しい順/ 古い順}.
初期・ページの表示・位置:{ 先頭ページ/ 末尾ページ}.
1ページ内のスレッド表示数:

   
   

管理者用 Password:

  




SMT Version 8.022(+A) Release M6.
Author : amanojaku.