Добавлено через 7 минут
Написал.
Пришлось воспользоваться другим методом

Держите, кому надо
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
| #include <iostream>
#include <fstream>
#include <windows.h>
using namespace std;
int main() {
int size_array = 0;
int i = 0;
ifstream input;
ofstream output;
FILE* file;
char data[30];
cout << "input file: ";
cin.getline(data, 30);
input.open(data);
char output1[30];
cout << "output file: ";
cin.getline(output1, 30);
output.open(output1);
file = fopen(data, "r"); // only read
if(file == NULL) {
cout << "File " << data << " not found!" << endl;
cin.get();
return 0;
}
while(!feof(file)) {
fscanf(file, "%f", &i);
size_array++;
}
int N = size_array;
float array[N];
ifstream f(data);
for(int i = 0; i < N; i++) {
f >> array[i];
}
for(int i = N-1; i >= 1; i--)
for(int j = 0; j < i; j++) {
if(array[j]> array[j+1]) {
float temp(0);
temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
for(int i = 0; i < N; i++)
output << array[i] << endl;
char szPath[256];
GetModuleFileName(NULL, szPath, sizeof(szPath));
ShellExecute(0, "open", output1, NULL, NULL, SW_SHOW);
return 0;
} |
|
P.S. Отошел

) УХ
UPD: Для ленивых добавил автооткрытие output файла, и чек на существование input файла