반응형

백준 문제 풀이


https://www.acmicpc.net/group/practice/3060/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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//A - We love kriii
 
#include <iostream>
 
using namespace std;
 
int main()
{
    cout << "강한친구 대한육군" << endl;
    cout << "강한친구 대한육군" << endl;
 
    return 0;
}
 
//B - 그대로 출력하기
 
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
    // 1번 방법
    char tmp[101];
    while (cin.getline(tmp, sizeof(tmp)))
        cout << tmp << endl;
    
    // 2번 방법
    char ch;
    while ((ch = getchar()) != EOF)
        cout << ch;
 
    // 3번 방법
    string str;
    while (getline(cin, str))
        cout << str << endl;
 
    return 0;
}
 
//C - A + B
 
#include <iostream>
 
using namespace std;
 
int main()
{
    int a, b;
    cin >> a >> b;
    cout << a + b;
 
    return 0;
}
 
//D - A - B
 
#include <iostream>
 
using namespace std;
 
int main()
{
    int a, b;
    cin >> a >> b;
    cout << a - b;
 
    return 0;
}
 
//E - N 찍기
 
#include <iostream>
#include <cstdio>
 
using namespace std;
 
int main()
{
    int n;
    scanf("%d"&n);
 
    for (int i = 0; i < n; i++)
        printf("%d\n", i + 1);
 
    return 0;
}
 
//F - 별찍기 - 1
 
#include <iostream>
 
using namespace std;
 
int main()
{
    int n;
    cin >> n;
 
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < i; j++)
        {
            cout << '*';
        }
        cout << endl;
    }
 
    return 0;
}
 
//G - 그대로 출력하기 2
 
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
    // 1번 방법
    char tmp[101];
    while (cin.getline(tmp, sizeof(tmp)))
        cout << tmp << endl;
 
    // 2번 방법
    char ch;
    while ((ch = getchar()) != EOF)
        cout << ch;
 
    // 3번 방법
    string str;
    while (getline(cin, str))
        cout << str << endl;
 
    return 0;
}
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus






연산자 오버로딩


http://www.crocus.co.kr/1193?category=278487



pair 이용


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <string.h>
 
using namespace std;
 
typedef pair<intint> pii;
 
int main()
{
    pii a;
    a.first = 1;
    a.second = 2;
    
    cout << a.first << " " << a.second << endl;
 
    return 0;
}
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus

반응형

'Tutoring > Data Structure' 카테고리의 다른 글

튜터링 단일 연결 리스트  (0) 2018.04.18
튜터링 atoi, 후위 표기식  (0) 2018.04.11
hash  (0) 2018.03.04
heap  (0) 2018.03.04
Tree, Binary Tree, Tree traversal  (0) 2018.03.01