summary refs log tree commit diff
path: root/tests/pracownia4/01_sort.xi
blob: e875eaf2ea5f432d237b898f1b51b6ca4fe77cda (plain) (blame)
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
printString(x:int[])

sort(a: int[]) {
  i:int = 0
  n:int = length(a)
  while (i < n) {
      j:int = i
      while (j > 0) {
        if (a[j-1] > a[j]) {
            swap:int = a[j]
            a[j] = a[j-1]
            a[j-1] = swap
        }
        j = j-1
      }
      i = i+1
  }
}


main():int
{
    x:int[] = "Wroclaw"
    sort(x)
    printString(x)
    return 1
}

//@PRACOWNIA
//@out Waclorw
//@out Exit code: 1