U E D R , A S I H C RSS

정렬/곽세환

데블스캠프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;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:45
Processing time 0.0119 sec