[백준]10953번 A+B -6 c/c++
·
CS/백준 & 프로그래머스
문제 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
[백준]10952번 A+B -5 c/c++
·
CS/백준 & 프로그래머스
문제 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
[백준]11721번 열 개씩 끊어 출력하기 c/c++
·
CS/백준 & 프로그래머스
문제 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
[백준]10828번 스택 c/c++
·
CS/백준 & 프로그래머스
문제 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
[백준]10808번 알파벳 개수 c/c++
·
CS/백준 & 프로그래머스
문제 https://www.acmicpc.net/problem/10808 나의 해결방법 각 알파벳 위치를 구해 배열에 저장하는 방법을 사용했다. 다른 사람들의 코드를 보니 대부분 비슷하게 푼 것 같다. 코드 #include using namespace std; int main() { string s; cin >> s; int a[26] = { 0 }; //각 원소 0으로 초기화 for (int i = 0; i < s.size(); i++) { a[s[i] - &#39;a&#39;]++; //알파벳 위치를 구해 배열에 저장 } for (int i = 0; i < 26; i++) { cout