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


 

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; 

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM