본문 바로가기
728x90

PS35

[백준]10953번 A+B -6 c/c++ 문제 https://www.acmicpc.net/problem/10953 나의 해결방법 ,는 입력해줘야하지만 결과값에 영향을 미치는것이 아니므로 그냥 단지 입력해주는 역할만 한다. 코드 #include using namespace std; int main() { int tc; cin >> tc; char c; int a, b; for (int i = 0; i > a >> c >> b; //콤마는 그냥 입력만해주는 역할(?) cout 2022. 6. 27.
[백준]10952번 A+B -5 c/c++ 문제 https://www.acmicpc.net/problem/10952 나의 해결방법 a와 b가 0일때 while문 break해서 빠져나온다. #include using namespace std; int main() { int a, b; while (1) { cin >> a >> b; if (a == 0 && b == 0) { break; } cout 2022. 6. 27.
[백준]11721번 열 개씩 끊어 출력하기 c/c++ 문제 https://www.acmicpc.net/problem/11721 나의 해결방법 getline으로 문자열을 받고 for문을 돌리며 알파벳을 원소마다 출력하고 10번째 원소를 출력했을때 줄바꿈을 출력해준다. 코드 #include #include using namespace std; int main() { string s; getline(cin, s); for (int i = 0; i < s.size(); i++) { //문자열 길이만큼 cout 줄바꿈 출력 cout 2022. 6. 27.
[백준]10828번 스택 c/c++ 문제 https://www.acmicpc.net/problem/10828 1. c++의 stack 헤더를 사용하여 풀이 #include #include #include using namespace std; int main() { stack stk; //스택 생성 int t, num; cin >> t; //테스트케이스 개수 for (int i = 0; i > s; //문자열 입력 if (s == "push") { //push cin >> num; stk.push(num); } else if (s == "pop") { //pop if (stk.empty() == true) { cout 2022. 6. 26.
728x90