[C++] 백준 20단계 - 18258번 문제 (큐 2)
자료구조 & 알고리즘/BOJ2023. 7. 10. 18:06[C++] 백준 20단계 - 18258번 문제 (큐 2)

문제설명 소스코드 #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); //표준 스트림 동기화 해제 cin.tie(NULL); //입력과 출력 연결 끊기 queue que; string command; int N; cin >> N; for (int i = 0; i > command; if (command == "push") { int X; cin >> X; que.push(X); } else if (command == "pop") { if (que.empty()) cout

[C++] 백준 - 10845번 문제 (큐)
자료구조 & 알고리즘/BOJ2023. 6. 26. 20:42[C++] 백준 - 10845번 문제 (큐)

문제설명 소스코드 #include using namespace std; int max = 10000; //큐 용량 int num = 0; //현재 데이터 수 int que[10000]; bool isFull() { return ::num >= ::max; } //큐의 공간이 모두 사용중인지 리턴 bool isEmpty() { return ::num 0) return que[0]; } int main() { int N; cin >> N; for (int i = 0; i > command; if (command == "push") { cin >> value; enque(value); } else if (command ==..

[C++] 백준 6단계 - 4344번 문제 (평균은 넘겠지)
자료구조 & 알고리즘/BOJ2023. 6. 26. 17:55[C++] 백준 6단계 - 4344번 문제 (평균은 넘겠지)

23.06.26 재채점 결과 반영 이전에는 맞았지만 재채점후 틀린 이유는 https://www.acmicpc.net/board/view/119087때문이다. 따라서 반올림 함수인 round()를 이용하여 다시 풀었다. 문제설명 소스코드 #include #include //round 함수를 쓰기위해 using namespace std; int main() { int tmp; int N; cin >> N; tmp = N; for (int i = 0; i > N; int* arr = new int[N]; //동적할당 float avg = 0; int count = 0; //평균을 넘는 사람의 수를 저장 for (int j = 0; j > arr[..

[C++] 백준 12단계 - 2231번 문제 (분해합)
자료구조 & 알고리즘/BOJ2023. 6. 25. 06:03[C++] 백준 12단계 - 2231번 문제 (분해합)

문제설명 소스코드 #include #include using namespace std; int main() { int N; int ans = 0; cin >> N; for (int i = 1; i < N; ++i) { string str = to_string(i); //i를 문자열로 바꿈 string* arr = new string[str.length()]; //i의 자리수 만큼 string 타입 배열 동적할당 for (int j = 0; j < str.length(); ++j) arr[j] = str[j]; //i의 각 자리수를 복사 int sum = i; //분해합에선 자기 자신을 더해야하므로 for (int j = 0; j < str.length(); ++j) sum += stoi(arr[j]); ..

[C++] 백준 12단계 - 2798번 문제 (블랙잭)
자료구조 & 알고리즘/BOJ2023. 6. 25. 03:48[C++] 백준 12단계 - 2798번 문제 (블랙잭)

문제설명 소스코드 #include using namespace std; int main() { int N, M, ans; int sum = 0; int margin = 300000; //M과 세 수의 합의 최대 차이는 300000이므로 cin >> N >> M; int* arr = new int[N]; //동적 할당 for (int i = 0; i > arr[i]; for (int i = 0; i = 0) && (M - sum..

[C++] 백준 19단계 - 18028번 문제 (스택)
자료구조 & 알고리즘/BOJ2023. 6. 25. 02:57[C++] 백준 19단계 - 18028번 문제 (스택)

문제설명 소스코드 #include using namespace std; int max_stack = 10000; int ptr = 0; int stk[10000]; bool isFull() { return ptr >= max_stack; } bool isEmpty() { return ptr

[JAVA] 백준 - 11282번 문제 (한글)
자료구조 & 알고리즘/BOJ2023. 6. 23. 18:13[JAVA] 백준 - 11282번 문제 (한글)

문제설명 소스코드 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println((char)(sc.nextInt()-1+'가')); } } 설명 import java.util.*; public class Main { public static void main(String[] args) { System.out.println((char)44032 + " = " + (int)'가'); for(int i = 0; i < 11172; ++i){ if(i % 50 == 0)System.out.println(); System.out.pr..

[C++] 백준 - 13416번 문제 (주식 투자)
자료구조 & 알고리즘/BOJ2023. 6. 22. 21:59[C++] 백준 - 13416번 문제 (주식 투자)

문제설명 소스코드 #include using namespace std; int main() { int T; int N; int sum = 0; cin >> T; for (int i = 0; i > N; int** arr = new int* [N]; //N개의 배열 동적할당 for (int k = 0; k > arr[j][k]; if (arr[j][k] > dm) dm = arr[j][k]; // 당일 이익 최고가 저장 } sum += dm..

image