목록분류 전체보기 (83)
천천히 빛나는
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/DqYXu/btstlnfTlbA/VKPWp0Ropiv0r0kE6iKah1/img.png)
27323. 정수 A, B 가 주어진다. 세로 길이가 A cm, 가로 길이가 B cm 인 아래와 같은 직사각형의 넓이를 cm2 단위로 구하시오. #include using namespace std; int main(){ int a, b; cin >> a >> b; cout > x >> y >> w >> h; cout > y[i]; } if (x[0] == x[1]) { if (y[0] == y[2]) { // 0 가운데 낀거 cout
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/yN5VV/btstmIwdsUL/vHwXKQUhCJ1LqguvFODgfK/img.png)
5086. 두 수가 주어졌을 때, 다음 3가지 중 어떤 관계인지 구하는 프로그램을 작성하시오. #include #include using namespace std; int main() { ios::sync_with_stdio; cin.tie(0); int x, y; while(1) { cin >> x >> y; if (x == 0 && y == 0) break; if (y % x == 0) { cout > k; while (k != count) { i++; if (i > n) { i = 0; break; } if (n % i == 0) { count++; } } cout > n; if (n == -1) break; for (int i = 2; i < n; i++) { if (n % i == 0) { di..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/byYgiH/btstg2bqNec/uM1UzCFeoevtsPY3bzSgP1/img.png)
2745. B진법 수 N이 주어진다. 이 수를 10진법으로 바꿔 출력하는 프로그램을 작성하시오. 10진법을 넘어가는 진법은 숫자로 표시할 수 없는 자리가 있다. 이런 경우에는 다음과 같이 알파벳 대문자를 사용한다. #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string N; int B; int dec = 0; cin >> N >> B; for (int i = 0; i = 'A') && (N[N.length() - i - 1] N >> B; string change =""; whi..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/tEY6e/btssVLG8ztd/XuVgObdecrGHtqCXdjTvS0/img.png)
문제 풀이 전, 2차원 배열 동적할당 방법을 소개하도록 하겠다. 행이 n, 열이 m인 2차원 배열이다. int n, m; cin >> n >> m; int** arr = new int* [n]; for (int i = 0; i < m; i++) { arr[i] = new int[m]; } 자바에서 소개했던 2차원 배열 모습인데 이렇게 생각하면 된다. 2738. N*M크기의 두 행렬 A와 B가 주어졌을 때, 두 행렬을 더하는 프로그램을 작성하시오. #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; int arr1[101][101] = {0}; int arr2[101][101..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/OMqnU/btssS1qB9oN/cRfNKMx1MU2Yt1qC0YbnYK/img.png)
25083. 아래 예제와 같이 새싹을 출력하시오. #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout > num; piece[i] -= num; } for (int i = 0; i < 6; i++) { cout n; for (int i = 1; i str; for (int j = 0; j < str.length(); j++) { int last = j; for (int k = j+1; k < str.length(); k++) { if (str[j] == str[k]) { if (last != k - 1) { group = 0; break; } else { last = k; } } } if (grou..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/c4rrMb/btssGwReJua/5lD5qksREKdDle8KFREyCk/img.png)
27866. 단어 S와 정수 i가 주어졌을 때, S의 i번째 글자를 출력하는 프로그램을 작성하시오. #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string s; int i; cin >> s >> i; cout > s; cout > t; for (int i = 0; i > s; cout n; char* c = new char[n+1]; cin >> c; int sum = 0; for (int i = 0; i < n; i++) { sum += int(c[i]) - '0'; } cout s; int n = s.length(); int location[26];..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/cA5NYi/btsryo0wouB/diFsHIFNIFqslF7qHDghw1/img.png)
10807. 총 N개의 정수가 주어졌을 때, 정수 v가 몇 개인지 구하는 프로그램을 작성하시오. #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, v; cin >> n; int* arr = new int[n]; for (int i = 0; i > arr[i]; } cin >> v; int count = 0; for (int i = 0; i n >> x; int* a = new int[n]; for (int i = 0; i > a[i]; } fo..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/NXTjR/btsrjpTuECI/DzC1a6DQU5kydZKdQXBbeK/img.png)
10950. 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. #include using namespace std; int main() { int n; cin >> n; for (int i = 1; i > n; int item, price, total = 0; for (int i = 0; i > item >> price; total += item * price; } if (x == total){ cout b; cout b) { ... } 위와 같은 방식도 가능하다. cin이 조건문 안에 있는 경우에 연산자 오버로딩에 의해 bool..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/be96nD/btsrcsXjGva/7IBz6QmREpV3H1qk9K77ok/img.png)
1330. 두 정수 A와 B가 주어졌을 때, A와 B를 비교하는 프로그램을 작성하시오. #include using namespace std; int main() { int a, b; cin >> a >> b; if (a > b) { cout = 90) { cout = 80) { cout = 70) { cout = 60) { cout year; if ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))) { cout x >> y; if ((x > 0) && (y > 0)) { cout c; a += c / 60; b += c % 60; if (b >= 60) { b -= 60; a += 1; } if (a >= 24) { a -= 24; } cout ..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/Ocrbj/btsq5dr7ZVv/K58nfKOu6G5aDn8MoiugIK/img.png)
2557. Hello World!를 출력하시오. #include using namespace std; int main(){ cout A >> B; cout > a >> b;와 같이 계속해서 입력을 받을 수 있다. 1001. 두 정수 A와 B를 입력받은 다음, A-B를 출력하는 프로그램을 작성하시오. #include using namespace std; int main(){ int A, B; cin >> A >> B; cout > A >> B; cout > A >> B; cout > B; cout