SWEA/Intermediate
[SWEA] 1229. [S/W 문제해결 기본] List - 암호문2
J_Jayce
2019. 8. 6. 12:37
문제
https://www.swexpertacademy.com/main/learn/course/lectureProblemViewer.do
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
www.swexpertacademy.com
풀이
이 문제는 암호문 1에서 없던 삭제 기능을 추가하여 구현한 코드이다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
public class Solution {
static Scanner scan = new Scanner(System.in);
static int len, num;
static LinkedList<Integer> list = new LinkedList<Integer>();;
static void read_command() {
num = scan.nextInt();
for(int j=0;j<num;j++) {
int idx,p_num;
idx = scan.nextInt();
p_num = scan.nextInt();
if(op == 'I') {
for(int k=0;k<p_num;k++)//삽입
list.add(idx+k, scan.nextInt());
}
else {//인덱스 자리에서 삭제되면 그 자리에 채워지기 때문에 그 위치에서 계속 삭제하면 됨
for(int k=0;k<p_num;k++)
}
}
}
static void print_password() {
for(int j=0;j<10;j++)
System.out.println();
}
static void solution() {
for (int i = 1; i <= 10; i++) {
len = scan.nextInt();
//암호문 입력
for(int j=0;j<len;j++)
list.add(scan.nextInt());
//명렁어 입력
read_command();
//10게 출력
System.out.print("#"+i+" ");
print_password();
//리스트 초기화
list.removeAll(list);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
solution();
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|