题目1066:字符串排序

2014-11-24 10:54:48 · 作者: · 浏览: 0
题目描述:

输入一个长度不超过20的字符串,对所输入的字符串,按照ASCII码的大小从小到大进行排序,请输出排序后的结果

输入:

一个字符串,其长度n<=20

输出:

输入样例可能有多组,对于每组测试样例,

按照ASCII码的大小对输入的字符串从小到大进行排序,输出排序后的结果
样例输入:
dcba
样例输出:
abcd
来源:

2001年清华大学计算机研究生机试真题(第II套)

#include
              
               
#include
               
                 #include
                
                  int main() { char *a=(char *)malloc(sizeof(char)); int len,i,j,temp,flag; while(scanf("%s",a)!=EOF) { len=strlen(a); for(i=0;i
                 
                  a[j+1]) { flag=0; temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } if(flag) break; } printf("%s\n",a); } return 0; } /************************************************************** Problem: 1066 Language: C Result: Accepted Time:110 ms Memory:912 kb ****************************************************************/
                 
                
               
              



<script type="text/java script">
<script type="text/java script">BAIDU_CLB_fillSlot("771048");
点击复制链接 与好友分享! 回本站首页
<script> function copyToClipBoard(){ var clipBoardContent=document.title + '\r\n' + document.location; clipBoardContent+='\r\n'; window.clipboardData.setData("Text",clipBoardContent); alert("恭喜您!复制成功"); }
分享到: 更多
<script type="text/java script" id="bdshare_js" data="type=tools&uid=12732"> <script type="text/java script" id="bdshell_js"> <script type="text/java script"> var bds_config = {'snsKey':{'tsina':'2386826374','tqq':'5e544a8fdea646c5a5f3967871346eb8'}}; document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js cdnversion=" + Math.ceil(new Date()/3600000)
您对本文章有什么意见或着疑问吗?请到 论坛讨论您的关注和建议是我们前行的参考和动力
上一篇: C/C++的内存泄漏检测工具Valgrind memcheck的使用经历(求大神解答疑惑,找出内存泄露真凶)
下一篇: 最后一页
相关文章
C++箴言:理解Terminology术语
<script type="text/java script">BAIDU_CLB_fillSlot("182716");
<script type="text/java script">BAIDU_CLB_fillSlot("517916");
图文推荐
<iframe src="http://www.2cto.com/uapi.php tid=286622&catid=339&title=zOLEvzEwNjajutfWt/u0rsXF0PI=&forward=http://www.2cto.com/kf/201403/286622.html" width="100%" height="100%" id="comment_iframe" name="comment_iframe" frameborder="0" scrolling="no">
<script type="text/java script">BAIDU_CLB_fillSlot("771057");