#include <iostream>
#include <string>
using namespace std;
int main() {
string words[10];
string temp;
int i, j, n, x;
cout<<"입력을 종료하려면 그낭 엔터를 누르세요 "<<endl;
i=0;
while(i<10) {
cout<<i+1<<"번째 단어 : ";
getline(cin, words[i]);
if(words[i]=="") break;
i=i+1;
}
n=i;
for(i=0;i<n-1;++i) {
x=i;
for(j=i+1;j<n;++j)
if(words[x]>words[j]) x=j;
temp=words[i];
words[i]=words[x];
words[x]=temp;
}
for(i=0;i<n;++i) cout<<words[i]<<" ";
return 0;
}
'c·c++ > c++ 프로그래밍' 카테고리의 다른 글
단어 갯수세기 (0) | 2012.08.31 |
---|---|
삼각형의 외심 구하기 (0) | 2012.08.23 |
숫자열에서 한숫자씩 입력받기 (0) | 2012.07.08 |
패스워드 파일을 읽고 처리하는 간단한 예제 (0) | 2012.05.29 |
sstream의 활용 - sscanf (0) | 2012.05.16 |