• 코드:
​x
 
1
#include <iostream>
2
#include <string>
3
using namespace std;
4
​
5
int main(void)
6
{
7
    string str1 = "ABC";
8
    string str2 = "ABD";
9
    
10
    if (str1.compare(str2) == 0)
11
    {
12
        cout << str1 << "가(이) " << str2 << "와 같습니다.";
13
    }
14
    else if (str1.compare(str2) < 0)
15
    {
16
        cout << str1 << "가(이) " << str2 << "보다 사전 편찬 순으로 앞에 있습니다.";
17
    }
18
    else
19
    {
20
        cout << str1 << "가(이) " << str2 << "보다 사전 편찬 순으로 뒤에 있습니다.";
21
    }
22
    return 0;
23
}
표준입력 & 실행옵션