source:
Deliverables/D2.2/8051/tests/clight/testCOMP_tri.c
@
486
Last change on this file since 486 was 486, checked in by , 10 years ago | |
---|---|
File size: 318 bytes |
Rev | Line | |
---|---|---|
[486] | 1 | void tri (int t[], int n) { |
2 | int i,j,tmp; | |
3 | tmp = 0; | |
4 | ||
5 | for(i = 0 ;i < n; i=i+1) | |
6 | { | |
7 | for(j = 1 ; j < n-i ; j=j+1) | |
8 | { | |
9 | if(t[j] < t[j-1]) | |
10 | { | |
11 | tmp = t[j-1]; | |
12 | t[j-1] = t[j]; | |
13 | t[j] = tmp; | |
14 | } | |
15 | } | |
16 | } | |
17 | } | |
18 | ||
19 | int main(){ | |
20 | int t[10] = {10,9,8,7,6,5,4,3,2,1}; | |
21 | tri(t,10); | |
22 | return t[0]; | |
23 | } |
Note: See TracBrowser
for help on using the repository browser.