- 450 名前:デフォルトの名無しさん mailto:sage [2009/10/29(木) 14:51:32 ]
- >>449
#include <iostream> using namespace std; template <typename T> void b_sort(T a[], int n) { for (int i = 0; i < n - 1; ++i) { for (int j = n - 1; j > i; --j) { if (a[j - 1] > a[j]) { T temp = a[j]; a[j] = a[j - 1]; a[j - 1] = temp; } } } } int main() { int a[] = { 3, 8, 1, -1, 9, 8, 7 }; double b[] = { 3.09, 2.1, -9.27, 8.0, 3.11, -6.5 }; b_sort(a, 7); for (int i = 0; i < 7; ++i) cout << a[i] << ' '; cout << endl; b_sort(b, 6); for (int i = 0; i < 6; ++i) cout << b[i] << ' '; cout << endl; return 0; }
|

|