#include <iostream>
#include <string>
using namespace std;
void main()
{
string hello[] = { "January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December" };
int A = sizeof(hello) / sizeof(string);
for (int i = 0; i < A; ++i)
{
for (int j = 0; j < i; ++j)
{
if (hello[i].at(0) < hello[j].at(0))
{
string helloTemp = hello[i];
hello[i] = hello[j];
hello[j] = helloTemp;
}
}
}
cout << "출력결과 : " << endl;
for (int i = 0; i < A; ++i)
cout << hello[i] << endl;
cout << endl;
}
이거 출력 결과가
출력결과 :
April
August
December
February
July
January
June
March
May
November
October
September
이건데
굵게 칠해놓은 July랑 January 위치 어케 바꾸냐? 플밍좆밥이다 ㅠㅠ
hello[i].at(0) < hello[j].at(0) -> .at(0) 함수 지우세염...
아 .at를 지우라는거구나
오오 된다 고맙고맙 ㅋㅋ 근데 .at가 뭐냐?
[num] 연산자랑 똑같은거임. hello[num] == hello.at(num) - return 0;