공부/SWEA
[SWEA-11856] 반반 - Java
빈v
2022. 6. 21. 16:46
728x90
https://swexpertacademy.com/main/code/problem/problemDetail.do
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
SWEA 11856번 반반 자바 풀이
난이도: D3
코드
import java.util.Scanner;
public class swea11856 {
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T;
T=sc.nextInt();
for(int test_case = 1; test_case <= T; test_case++)
{
char ch[]=new char[4];
String str=sc.next();
int result=0;
for(int i=0;i<4;i++){
ch[i]=str.charAt(i);
}
for(int i=0;i<4;i++){
int count=0;
for(int j=0;j<4;j++){
if(ch[i]==ch[j]){
count++;
}
}
if(count==2){
result+=1;
}
}
if(result==4){
System.out.println("#"+test_case+" Yes");
}else{
System.out.println("#"+test_case+" No");
}
}
}
}
728x90
반응형