반응형
11328번: Strfry
C 언어 프로그래밍에서 문자열(string)은 native한 자료형이 아니다. 사실, 문자열은 그저, 문자열의 끝을 표시하기 위한 말단의 NULL이 사용된, 문자들로 이루어진 문자열일 뿐이다. 하지만 프로그래
www.acmicpc.net
string을 입력 받아서 begin~end까지 정렬해준다!
두 문자열이 같다면? Possible
다르다면 Impossible 출력
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main(void)
{
ios_base::sync_with_stdio;
cin.tie(0);
int num;
cin>>num;
int arr[1000];
for(int i=0; i<num; i++)
{
string s1;
string s2;
cin>>s1>>s2;
sort(s1.begin(),s1.end());
sort(s2.begin(),s2.end());
if(s1==s2)
arr[i]=0;
else
arr[i]=1;
}
for(int i=0;i<num;i++)
{
if(arr[i]==0)
cout<<"Possible"<<endl;
else
cout<<"Impossible"<<endl;
}
}
반응형
'알고리즘' 카테고리의 다른 글
[백준/10773번][C++] 제로 (0) | 2021.01.25 |
---|---|
[백준/5397번][C++] 키로거 (0) | 2021.01.25 |
[백준/1406번][C++] 에디터 (0) | 2021.01.25 |
[백준/1919번][C++] 에너그램 만들기 (0) | 2021.01.25 |
[백준/10171번][C++] 고양이 (0) | 2021.01.25 |