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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #include <iostream> #include <algorithm> #include <string> using namespace std; int code[4000]; void Insert( int x, int y, int length_code) { for ( int i=length_code-1; i>=x; i--) code[i+y]=code[i]; for ( int i=x; i<x+y; i++) cin >> code[i]; length_code+=y; } void Delete( int x, int y, int length_code) { for ( int i=x; i<length_code; i++) code[i]=code[i+y]; length_code-=y; } void Add( int y, int length_code) { for ( int i=length_code; i<length_code+y; i++) cin >> code[i]; length_code+=y; } int main() { for ( int T=1; T<=10; T++) { fill(code, code+4000,0); int length_code; int num_order; char order; string s; cin >> length_code; for ( int i=0; i<length_code; i++) cin >> code[i]; cin >> num_order; for ( int i=0; i<num_order; i++) { cin >> order; s=order; if (!s.compare( "I" )) { int x, y; cin >> x >> y; Insert(x,y,length_code); } else if (!s.compare( "D" )) { int x, y; cin >> x >> y; Delete(x,y,length_code); } else { int y; cin >> y; Add(y,length_code); } } cout << "#" << T ; for ( int i=0; i<10; i++) cout << " " << code[i]; cout << endl; } } |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
171109_5_그래픽 편집기 (0) | 2017.11.09 |
---|---|
171108_원재의 벽 꾸미기 (0) | 2017.11.08 |
171107_최소힙 (0) | 2017.11.07 |
171106_1234_비밀번호 (0) | 2017.11.06 |
171105_1228_암호문1 (0) | 2017.11.05 |