Description
输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。
Sample Input
qwe
asd
zxc
#include<iostream>
#include<string>
using namespace std;
int main(){
char c[3],t;
int i=0,j=0;
while(gets(c)){ //gets(接收一个字符串,可以接受空格并输出,需包含#include<string>;
//当输入的字符串不为空时,循环继续
for(i=0;i<2;i++) //冒泡排序
for(j=i+1;j<3;j++)
if(c[i]>c[j]){
t=c[i];c[i]=c[j];c[j]=t;
}
cout<<c[0]<<" "<<c[1]<<" "<<c[2]<<endl;
}
return 0;
}
问题:怎样才可以连续输入多组字符,最后再连续输出,而不是像现在这样只能一组一组地操作?