반응형
Strcmp(const *char,const *char): 두 문자열이 같은지 다른지를 비교해주는 함수입니다.
1.헤더는 <string.h> 나 <cstring>이 필요합니다.2.문자열이 같다면 0을 반환하고 다르다면 -1 또는 1을 반환해줍니다.#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main() {
int as, bs;
int i = 1;
while (1)
{
char a[1001], b[1001];
cin >> a >> b;
if (!strcmp(a, "END") && !strcmp(b, "END")) { break; }
as = strlen(a);
bs = strlen(b);
if (as != bs)
cout << "Case " << i++ << ": different" <<'\n';
else
{
sort(a, a + as);
sort(b, b + bs);
if(!strcmp(a,b))
cout << "Case " << i++ << ": same" << '\n';
else
cout << "Case " << i++ << ": different" << '\n';
}
}
}
'Algorithm' 카테고리의 다른 글
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 10984번:내 학점을 구해줘 답 (0) | 2019.01.25 |
---|---|
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 1003번 : 피보나치 함수 (0) | 2019.01.25 |
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 11899번:괄호 끼워넣기 답 (0) | 2017.04.16 |
(C++) - 백준(BOJ) 2721번 : 삼각수의 합 (0) | 2017.04.16 |
(C++) - 백준(BOJ) 3035 : 스캐너 답 (0) | 2017.04.16 |