-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.txt
83 lines (68 loc) · 1.39 KB
/
test2.txt
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import "fmt"
import "math/rand"
func main() {
/*
Operadores básicos
*/
a:= 3 * 100
b:= 2 * 100
fmt.Println("a = ", a)
fmt.Println("b = ", b)
fmt.Println("a+b = ", a+b)
fmt.Println("a-b = ", a-b)
fmt.Println("a*b = ", a*b)
fmt.Println("a/b = ", a/b)
//fmt.Println("a%b = ", a%b)
fmt.Println("a>b = ", a>b)
fmt.Println("a<b = ", a<b)
fmt.Println("a>=b = ", a>=b)
fmt.Println("a<=b = ", a<=b)
fmt.Println("true&&true = ", true && true)
}
func main() {
i := 1
for i <= 3 {
fmt.Println(i)
i = i + 1
}
for j := 7; j <= 9; j++ {
fmt.Println(j)
}
for n := 0; n <= 5; n++ {
if n%2 != 0 {
fmt.Println("Par: ", n)
}
}
for {
fmt.Println("loop")
break
}
}
/*
array[0] = 3
array[1] = 8
array[2] = 11
array[3] = 14
array[4] = 17
array[5] = 18
array[6] = 43
*/
func BubbleSort(array[] int, size int)[]int {
for i:=0; i< size-1; i++ {
for j:=0; j < size-i-1; j++ {
if (array[j] > array[j+1]) {
array[j] = array[j+1]
array[j+1] = array[j]
}
}
}
return array
}
func main() {
var size int = 7
array:= [7]int{11, 14, 3, 8, 18, 17, 43}
fmt.Println("Array before: ", array)
BubbleSort(array, size)
fmt.Println("\nArray after: ", array)
}