-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.txt
More file actions
52 lines (47 loc) · 870 Bytes
/
Copy pathinput.txt
File metadata and controls
52 lines (47 loc) · 870 Bytes
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
/* C-minus example code: Sorting */
int x[10];
int minloc (int a[], int low, int high)
{int i; int x; int k;
k = low;
x = a[low];
i = low + 1;
if (i < high) {
repeat
{ if (a[i] < x)
{ x= a[i];
k = i; } else { } endif
i = i + 1;
} until (high < i + 1)
} endif
return k;
}
void sort (int a[], int low, int high) {
int i;
int k;
i = low;
if (i < high - 1) {
repeat {
int t;
k = minloc(a,i,high);
t = a[k];
a[k] = a[i];
a[i] = t;
i = i+1;
} until (high - 2 < i)
} endif
}
void main(void)
{
int i;
i = 0;
repeat {
x[i] = (10 - i) * (10 - i);
i = i + 1;
} until (9 < i)
sort(x,0,10);
i = 0;
repeat {
output(x[i]);
i = i + 1;
} until (9 < i)
}