/* * Copyright (c) 1999 Tony Givargis. Permission to copy is granted * provided that this header remains intact. This software is provided * with no warranties. * * Version : 2.4 */ /*---------------------------------------------------------------------------*/ #include <reg51.h> /*---------------------------------------------------------------------------*/ void sort(unsigned char* buf, unsigned char n) { unsigned char i, j, t; for(i=0; i<n; i++) { for(j=i; j<n; j++) { if( buf[i] > buf[j] ) { t = buf[i]; buf[i] = buf[j]; buf[j] = t; } } } P0 = 0; } /*---------------------------------------------------------------------------*/ void print(unsigned char* buf, unsigned char n) { char i; for(i=0; i<n; i++) { P0 = buf[i]; } } /*---------------------------------------------------------------------------*/ void main() { unsigned char buf[] = { 19, 18, 17, 16, 15, 14, 13, 12, 11, 10 }; while (1) { buf[0] = 19; buf[1] = 18; buf[2] = 17; buf[3] = 16; buf[4] = 15; buf[5] = 14; buf[6] = 13; buf[7] = 12; buf[8] = 11; buf[9] = 10; sort(buf, 10); print(buf, 10); } } <div align="center"><br /><script type="text/javascript"><!-- google_ad_client = "pub-7293844627074885"; //468x60, Created at 07. 11. 25 google_ad_slot = "8619794253"; google_ad_width = 468; google_ad_height = 60; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><br /> </div>