/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
//**********************
// 高二進階程式設計 *
// 大樂透程式開發 *
// 205-xx-XXX *
// <六個數字的排序> *
//**********************
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <algorithm>
using namespace std;
int main()
{
// 宣告陣列
const int SIZE = 6;
int result[SIZE];
// 隨機數生成
srand(time(NULL));
for (int i = 0; i < SIZE; i++) {
result[i] = rand() % 49 + 1;
}
// 顯示排序前的陣列
cout << "排序前: ";
for (int i = 0; i < SIZE; i++) {
cout << result[i] << " ";
}
cout << endl;
// 排序
sort(result, result + SIZE);
// 顯示排序後的陣列
cout << "排序後: ";
for (int i = 0; i < SIZE; i++) {
cout << result[i] << " ";
}
cout << endl;
return 0;
}