본문 바로가기

분류 전체보기

(86)
백준 15964번 이상한 기호 https://www.acmicpc.net/problem/15964 아이디어:함수를 사용할 수 있는지 묻는 문제long 자료형 사용 // 15964#include using namespace std;long calc(long a, long b) { return (a + b) * (a - b);}int main() { ios::sync_with_stdio(false); cin.tie(NULL); long n, m, answer; cin >> n >> m; answer = calc(n, m); cout
백준 2754번 학점계산 https://www.acmicpc.net/problem/2754 아이디어:1. 소수점 고정 cout 2. 입력받은 학점의 첫째 알파벳과 뒤 +, -, 0을 구분해서 조건문 사용 // 2754#include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); string a; float score; cin >> a; cout
백준 2744번 대소문자 바꾸기 https://www.acmicpc.net/problem/2744 아이디어:1. string 자료형 사용 > for문, 배열처럼 접근 가능2. ascii코드 값 활용 > 대문자 + 32 = 소문자, 소문자 - 32 = 대문자 // 2744#include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); string str; cin >> str; for (int i = 0; i
백준 10872번 팩토리얼 https://www.acmicpc.net/problem/10872 아이디어:1. 원래라면 dp를 써서 푸는게 맞는데, N 범위가 낮아서 반복문 사용2. 결과값이 커서 long 자료형 사용3. 결과값 변수는 1로 초기화하고 반복문도 1부터 시작한다. // 10872#include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; long answer = 1; cin >> n; for (int i = 1; i
백준 2741번 N 찍기 https://www.acmicpc.net/problem/2741 아이디어:for문으로 출력 // 2741#include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; for (int i = 0; i