본문 바로가기
반응형

백준24

C++ BAEKJOON 15552번 빠른 A+B [C++] BAEKJOON 15552번 : 빠른 A+B 방법 1 : C 표준 입출력 stdio.h 쓰기C언어의 표준 입출력 scanf()와 printf() 사용해당 입출력은 매우 빠른편이다. 방법 2 :  iostream의 default 설정을 수정1. C++와 C 표준 스트림의 동기화 해제 : ios_base::sync_with_stdio(false);를 추가2. 입력과 출력 연결을 끊어주기 : cin.tie(NULL);#include using namespace std;int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; int a, b; cin >> n; for (int i = 0; i > a.. 2022. 8. 17.
C++ BAEKJOON 25304번 영수증 [C++] BAEKJOON 25304번 : 영수증 #include using namespace std;int main(){ ios_base::sync_with_stdio(false); //cin.tie(NULL); int x, n, a, b, sum = 0; cin >> x >> n; for (int i = 0; i > a >> b; sum += a * b; } if (x == sum) { cout 2022. 8. 17.
C++ BAEKJOON 8393번 합 [C++] BAEKJOON 8393번 : 합 #include using namespace std;int main(){ int n; int sum = 0; cin >> n; for (int i = 1; i 2022. 8. 17.
C++ BAEKJOON 10950번 A+B [C++] BAEKJOON 10950번 : A+B #include using namespace std;int main(){ int n; int a, b; cin >> n; for (int i = 0; i > a >> b; cout 2022. 8. 17.
C++ BAEKJOON 2739번 구구단 [C++] BAEKJOON 2739번 : 구구단  #include using namespace std;int main(){ int n; cin >> n; for (int i = 1; i 2022. 8. 17.
C++ BAEKJOON 2480번 주사위 세 개 [C++] BAEKJOON 2480번 : 주사위 세 개 #include using namespace std;int main(){ int a, b, c, result = 0; cin >> a >> b >> c; if (a == b) { result = 1000 + a * 100; if (b == c) { result = 10000 + a * 1000; } } else if (a == c) { result = 1000 + a * 100; } else if (b == c) { result = 1000 + b * 100; } else { int max = a > b ? ((a > c) ? a : c) : ((b > c) ? b : c); result = max * 100; } cout 2022. 8. 17.
C++ BAEKJOON 2525번 오븐 시계 [C++] BAEKJOON 2525번 : 오븐 시계  #include using namespace std;int main(){ int h, m, t; cin >> h >> m >> t; int M = m + t; m = M % 60; h = (h + M / 60) % 24; cout 2022. 8. 17.
C++ BAEKJOON 2884번 알람 시계 [C++] BAEKJOON 2884번 : 알람 시계  #include using namespace std;int main(){ int h, m; cin >> h; cin >> m; if (m >= 45) { cout 2022. 8. 17.
C++ BAEKJOON 14681번 사분면 고르기 [C++] BAEKJOON 14681번 : 사분면 고르기  #include using namespace std;int main(){ int x, y; cin >> x; cin >> y; if (x > 0) { if (y > 0) { cout 0) { cout 2022. 8. 17.
C++ BAEKJOON 2753번 윤년 [C++] BAEKJOON 2753번 : 윤년 if 안에 if 안에 if 를 잘 해석해 보자#include using namespace std;int main(){ int a; cin >> a; bool y = false; if (a % 4 == 0) { y = true; if (a % 100 == 0) { y = false; if (a % 400 == 0) { y = true; } } } cout 2022. 8. 17.
C++ BAEKJOON 9498번 시험 성적 [C++] BAEKJOON 9498번 : 시험 성적 if 문 다음에 오는 else if문은 독립적으로 사용될 수 없고 if문 다음에 오게된다.else if 는 if가 아닐 경우 다른 조건문을 제시하는 구문이다.else는 위 조건식에 아무것도 해당되지 않을 경우 실행되는 구문이다. if나 else if의 조건식이 맞을 경우 포함된 실행문을 실행 후 else 이후로 탈출한다.#include using namespace std;int main(){ int a; cin >> a; if (a >= 90) cout = 80) cout = 70) cout = 60) cout 2022. 8. 17.
C++ BAEKJOON 1330번 두 수 비교하기 [C++] BAEKJOON 1330번 : 두 수 비교하기 두 수를 입력 받는다.if 문에서 중괄호를 생략하면 한 문장(세미콜론(;)을 만나기 까지)만 영향을 받는다.#include using namespace std;int main(){ int a, b; cin >> a; cin >> b; if (a > b) cout "; if (a 2022. 8. 17.
반응형