# -*- coding: utf-8 -*- # filename: progs_sort1.rb # # プログラム設計: rubyを用いてプログラミング: 単純ソート処理 # # > ruby progs_sort1.c x = Array.new(10) n = 5 x[1] = 40 x[2] = 20 x[3] = 50 x[4] = 10 x[5] = 30 for i in 1..n-1 for j in i..n if x[i] > x[j] w = x[i] x[i] = x[j] x[j] = w end end end for i in 1..n print i, "番目の要素 - ", x[i], "\n" end