/*
* Copyright (c) 2014, 烟台大学计算机学院
* All rights reserved.
* 文件名称:test.cpp
* 作 者:李晓凯
* 完成日期:2015年 5 月 19 日
* 版 本 号:v1.0
*
* 问题描述:
* 输入描述:
* 程序输出:
*/
qwe
asd
zxc
e q w
a d s
c x z
代码:
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
char a[3],t;
int i,j;
while(gets(a))
{
for(i=0; i<3; ++i)
for(j=0; j<3; ++j)
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
}
return 0;
}
学习总结:这个题目,好郁闷啊!,提交了好多次,最后终于成功了,就是不知道,为什么while(gets(a))和while(1){gets(a)这两种写法的后一种为什么会输出超限,跪求大神解答,同求运算更快,更有效的算法,谢过了。
原文地址:http://blog.csdn.net/qq_21385857/article/details/45842951