#include void swap_if(int & x, int & y) { 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); } /* The "for" loop, just a convenient way to rewrite some loops for (A; B; C) D equivalent to A; while (B) { D C } */ for (int i = 0; i <= 10; i = i + 1) { fin >> A[i]; if (fin.fail()) break; } fin.close(); for (int line = 9; line >= 0; line = line - 1) for (int i = 0; i <= line; i = i + 1) swap_if(A[i], A[i+1]); for (int i = 0; i <= 9; i = i + 1) cout << A[i] << " "; cout << "\n"; }