-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask1_c.c
More file actions
47 lines (35 loc) · 726 Bytes
/
Copy pathtask1_c.c
File metadata and controls
47 lines (35 loc) · 726 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
#include<stdio.h>
void selection_sort(int *d);
int task1_c()
{
unsigned int delay_count = 0x1000000;
unsigned char *LED=(unsigned char *) 0x41200000;
int result[10];
int data[] = {8,2,4,3,6,7,1,5,10,9};
unsigned int i,k;
k=0;
while(1){
for(i=0; i<10 ;i++) result[i] = data[i];
selection_sort(result); // sorting data
for(i = 0; i<delay_count; i++); // time delay to see LED outputs
*LED=(unsigned char)result[k++];
if(k == 10) k = 0;
}
return 0;
}
void selection_sort(int *d)
{
int i,j,t,min;
for(i=0; i<9; i++)
{
min = i;
for(j=i+1; j<10; j++){
if (d[min]>d[j])
min = j;
}
t=d[i];
d[i]=d[min];
d[min]=t;
}
return;
}