#include void swap_if(int & x, int & y) // if x <= y, leave them alone, do nothing // if x > y, swap them { if (x > y) { int temp = x; x = y; y = temp; } } void main() { int A[10]; ifstream fin; fin.open("data"); if (fin.fail()) { cout << "Can't find file\n"; exit(1); } fin >> A[0]; fin >> A[1]; fin >> A[2]; fin >> A[3]; fin >> A[4]; fin >> A[5]; fin >> A[6]; fin >> A[7]; fin >> A[8]; fin >> A[9]; if (fin.fail()) { cout << "bad data or not enough data_\n"; exit(1); } fin.close(); swap_if(A[0], A[1]); swap_if(A[1], A[2]); swap_if(A[2], A[3]); swap_if(A[3], A[4]); swap_if(A[4], A[5]); swap_if(A[5], A[6]); swap_if(A[6], A[7]); swap_if(A[7], A[8]); swap_if(A[8], A[9]); swap_if(A[0], A[1]); swap_if(A[1], A[2]); swap_if(A[2], A[3]); swap_if(A[3], A[4]); swap_if(A[4], A[5]); swap_if(A[5], A[6]); swap_if(A[6], A[7]); swap_if(A[7], A[8]); swap_if(A[0], A[1]); swap_if(A[1], A[2]); swap_if(A[2], A[3]); swap_if(A[3], A[4]); swap_if(A[4], A[5]); swap_if(A[5], A[6]); swap_if(A[6], A[7]); swap_if(A[0], A[1]); swap_if(A[1], A[2]); swap_if(A[2], A[3]); swap_if(A[3], A[4]); swap_if(A[4], A[5]); swap_if(A[5], A[6]); swap_if(A[0], A[1]); swap_if(A[1], A[2]); swap_if(A[2], A[3]); swap_if(A[3], A[4]); swap_if(A[4], A[5]); swap_if(A[0], A[1]); swap_if(A[1], A[2]); swap_if(A[2], A[3]); swap_if(A[3], A[4]); swap_if(A[0], A[1]); swap_if(A[1], A[2]); swap_if(A[2], A[3]); swap_if(A[0], A[1]); swap_if(A[1], A[2]); swap_if(A[0], A[1]); cout << A[0] << " "; cout << A[1] << " "; cout << A[2] << " "; cout << A[3] << " "; cout << A[4] << " "; cout << A[5] << " "; cout << A[6] << " "; cout << A[7] << " "; cout << A[8] << " "; cout << A[9] << " "; cout << "\n"; }