⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sort.c

📁 i8051 vhdl 文档
💻 C
字号:
/* * Copyright (c) 1999-2000 Tony Givargis.  Permission to copy is granted * provided that this header remains intact.  This software is provided * with no warranties. * * Version : 2.8 *//*---------------------------------------------------------------------------*/#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 };        sort(buf, 10);    print(buf, 10);    while(1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -