데블스캠프2003첫째날 정렬하기

~cpp 
#include <fstream>
using namespace std;

const int size = 10000;
int main()
{
	ifstream fin("unsorteddata.txt");
	ofstream fout("output.txt");
	int *data = new int[size];
	int i, j, temp;
	for (i = 0; i < size; i++)
		fin >> data[i];
	for (i = 0; i < size; i++)
		for (j = i; j < size; j++)
			if (data[i] > data[j])
			{
				temp = data[i];
				data[i] = data[j];
				data[j] = temp;
			}
	for (i = 0; i < size; i++)
		fout << data[i] << endl;

	return 0;
}

Retrieved from http://wiki.zeropage.org/wiki.php/정렬/곽세환
last modified 2021-02-07 05:30:45