码迷,mamicode.com
首页 > 其他好文 > 详细

将一组字符串按字典顺序输出

时间:2016-08-13 20:59:04      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:

 

1. 

将一组字符串按字典顺序输出。(通过函数调用完成)

#include <stdio.h> 

#include <string.h> 

//进行值得交换

 

void swap(char c[],int length)

      int i,j; 

     char temp; 

     for( i=0 ; i<length-1 ; i++)

    { 

         for(j=i+1 ; j<length ; j++)、

        { 

                if( (c[i] - c[j] ) > 0)

                { 

                      temp=c[i]; 

                      c[i]=c[j]; 

                      c[j]=temp;

                }

        } 

     } 

 

int main()

         char c[100];

         printf("请输入一窜字符:\n"); 

        gets(c); 

       swap(c,strlen(c)); 

       puts(c); 

       return 0; 

}

将一组字符串按字典顺序输出

标签:

原文地址:http://www.cnblogs.com/codeproject/p/5768658.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!