-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.CodeUnderstanding.cs
More file actions
53 lines (46 loc) · 835 Bytes
/
Copy path2.CodeUnderstanding.cs
File metadata and controls
53 lines (46 loc) · 835 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
53
using System;
class Qs
{
static void Qs(int[] a, int l, int h)
{
if (l < h)
{
int pI = P(a, l, h);
Qs(a, l, pI - 1);
Qs(a, pI + 1, h);
}
}
static int P(int[] a, int l, int h)
{
int p = a[h];
int i = l - 1;
for (int j = l; j < h; j++)
{
if (a[j] <= p)
{
i++;
S(a, i, j);
}
}
S(a, i + 1, h);
return i + 1;
}
static void S(int[] a, int i, int j)
{
int t = a[i];
a[i] = a[j];
a[j] = t;
}
static void P(int[] a)
{
foreach (var i in a)
{
C(i + " ");
}
C("");
}
static void C(object o)
{
Console.Write(o + " ");
}
}