#include void swap_if(int & x, int & y) { if (x > y) { int temp = x; x = y; y = temp; } } void main() { int A[1000]; ifstream fin; fin.open("data"); if (fin.fail()) { cout << "Can't find file\n"; exit(1); } int num; for (num = 0; num <= 1000; num = num + 1) { fin >> A[num]; if (fin.fail()) break; } cout << num << " numbers successfully read\n"; fin.close(); for (int line = num - 1; line >= 0; line = line - 1) for (int i = 0; i <= line; i = i + 1) swap_if(A[i], A[i+1]); ofstream fout; fout.open("data"); for (int i = 0; i <= num; i = i + 1) fout << A[i] << "\n"; fout.close(); }