#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, b, c, d, e, f, g, h, i, j; ifstream fin; fin.open("data"); if (fin.fail()) { cout << "Can't find file\n"; exit(1); } fin >> a; fin >> b; fin >> c; fin >> d; fin >> e; fin >> f; fin >> g; fin >> h; fin >> i; fin >> j; if (fin.fail()) { cout << "bad data or not enough data_\n"; exit(1); } fin.close(); swap_if(a, b); swap_if(b, c); swap_if(c, d); swap_if(d, e); swap_if(e, f); swap_if(f, g); swap_if(g, h); swap_if(h, i); swap_if(i, j); swap_if(a, b); swap_if(b, c); swap_if(c, d); swap_if(d, e); swap_if(e, f); swap_if(f, g); swap_if(g, h); swap_if(h, i); swap_if(a, b); swap_if(b, c); swap_if(c, d); swap_if(d, e); swap_if(e, f); swap_if(f, g); swap_if(g, h); swap_if(a, b); swap_if(b, c); swap_if(c, d); swap_if(d, e); swap_if(e, f); swap_if(f, g); swap_if(a, b); swap_if(b, c); swap_if(c, d); swap_if(d, e); swap_if(e, f); swap_if(a, b); swap_if(b, c); swap_if(c, d); swap_if(d, e); swap_if(a, b); swap_if(b, c); swap_if(c, d); swap_if(a, b); swap_if(b, c); swap_if(a, b); cout << a << " "; cout << b << " "; cout << c << " "; cout << d << " "; cout << e << " "; cout << f << " "; cout << g << " "; cout << h << " "; cout << i << " "; cout << j << " "; cout << "\n"; }