-
Notifications
You must be signed in to change notification settings - Fork 0
/
kegprak2.1.html
154 lines (150 loc) · 5.66 KB
/
kegprak2.1.html
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kegiatan Praktikum 2.1</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: blue;
margin: 0;
padding: 0;
}
.container {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
color: #333;
}
.code {
margin-bottom: 20px;
padding: 10px;
border-left: 5px solid #007bff;
background-color: #f8f9fa;
color: #333;
overflow-x: auto;
}
.code pre {
margin: 0;
padding: 0;
white-space: pre-wrap;
tab-size: 4;
}
.ButtonStyle {
text-align: center;
margin-top: 20px;
}
.styled {
border: 0;
line-height: 2.5;
padding: 0 20px;
font-size: 1rem;
text-align: center;
color: #fff;
text-shadow: 1px 1px 1px #000;
border-radius: 10px;
background-color: rgb(52, 35, 6);
background-image: linear-gradient(
to top left,
rgba(0, 0, 0, 0.2),
rgba(0, 0, 0, 0.2) 30%,
rgba(0, 0, 0, 0)
);
box-shadow:
inset 2px 2px 3px rgba(255, 255, 255, 0.6),
inset -2px -2px 3px rgba(0, 0, 0, 0.6);
}
.styled:hover {
background-color: rgb(84, 60, 10);
}
.styled:active {
box-shadow:
inset -2px -2px 3px rgba(255, 255, 255, 0.6),
inset 2px 2px 3px rgba(0, 0, 0, 0.6);
}
</style>
</head>
<body>
<div class="container">
<h1>Bubble Sort</h1>
<div class="code">
<pre><code> using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _2._1_BubbleSortAscendingDescending
{
internal class Program
{
static void BubblesortAscending(int[] array)//pengurutan bubble menaik
{
int nilai = array.Length;
for (int i = 0; i < nilai - 1; i++)
{
for (int j = 0; j < nilai - 1; j++)
{
if (array[j] > array[j + 1])
{
int tempatbariselemen = array[j];
array[j] = array[j + 1];
array[j + 1] = tempatbariselemen;
}
}
}
}
static void BubblesortDescending(int[] array)
{
int nilai = array.Length;
for (int i = 0; i < nilai - 1; i++)
{
for (int j = 0; j < nilai - 1; j++)
{
if (array[j] < array[j + 1])
{
int tempatbariselemen = array[j];
array[j] = array[j + 1];
array[j + 1] = tempatbariselemen;
}
}
}
}
static void MenampilkanArray(int[] array)
{
foreach (int angka in array)
{
Console.Write(angka + " ");
}
Console.WriteLine();
}
static void Main(string[] args)
{
int[] array = { 64, 34, 25, 12, 22, 11, 90 };
Console.WriteLine("Array sebelum pengurutan");
MenampilkanArray(array);
BubblesortAscending(array);
Console.WriteLine("\narray setea;ah pengurutan menaik");
MenampilkanArray(array);
BubblesortDescending(array);
Console.WriteLine("\narray setelah pengurutan menurun");
MenampilkanArray(array);
}
}
}
</code></pre>
</div>
</div>
<div class="ButtonStyle">
<button class="favorite styled" onclick="window.location.href='pre1.2.html'" type="button">Previous</button>
<button class="favorite styled" onclick="window.location.href='index.html'" type="button">Home</button>
<button class="favorite styled" onclick="window.location.href='kegprak2.2.html'" type="button">Next</button>
</div>
</body>
</html>