华为测试题图片排序(简单的冒泡排序)

来源:互联网 发布:mac下面的图标怎么换掉 编辑:程序博客网 时间:2024/05/21 22:38
#include <stdio.h>#include <string.h>int main(void){    char a[1024];    int i,num,len,j;    char temp;    gets(a);    len=strlen(a);    for(i=len-1;i>1;i--)    {   for (int j = 0; j<i; ++j)       {           /* code */            if (a[j]>a[j+1])            {                /* code */                temp = a[j+1];                a[j+1] = a[j];                a[j] = temp;            }       }    }     puts(a);     return 0;}

0 0