본문 바로가기

Beakjoon/else

(29)
[백준] 10951번 A+B - 4 (C++) 문제 https://www.acmicpc.net/problem/10951 10951번: A+B - 4 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net 코드 #include using namespace std; int main() { int a, b; while (cin >> a >> b) { cout a >> b를 읽은 후 스트림 객체가 반환되지만, 조건문 안에 있는 경우 연산자 오버로딩에 의해 bool값이 반환된다. 참조 https://st-lab.tistory.com/257
[백준] 2741번 N 찍기 (C++) 문제 https://www.acmicpc.net/problem/2741 2741번: N 찍기 자연수 N이 주어졌을 때, 1부터 N까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오. www.acmicpc.net 코드 #include using namespace std; int main() { int n; cin >> n; for (int i = 1; i
[백준] 2577번 숫자의 개수 (C++) 문제 https://www.acmicpc.net/problem/2577 2577번: 숫자의 개수 첫째 줄에 A, 둘째 줄에 B, 셋째 줄에 C가 주어진다. A, B, C는 모두 100보다 크거나 같고, 1,000보다 작은 자연수이다. www.acmicpc.net 코드 way1 #include #include using namespace std; int main(){ int a, b, c, result; cin >> a >> b >> c; result = a*b*c; string s = to_string(result); int array[10] = {0}; for(char c : s){ array[c-'0']+=1; } for (int e : array){ cout a >> b >> c; result = ..
[백준] 1152번 단어의 개수 (C++) 문제 https://www.acmicpc.net/problem/1152 1152번: 단어의 개수 첫 줄에 영어 대소문자와 공백으로 이루어진 문자열이 주어진다. 이 문자열의 길이는 1,000,000을 넘지 않는다. 단어는 공백 한 개로 구분되며, 공백이 연속해서 나오는 경우는 없다. 또한 문자열 www.acmicpc.net 코드 #include #include using namespace std; int main(){ string s; getline(cin, s); int length = s.length(); int num = 0; if(length == 0 || (length == 1 && s[0] == ' ')){ cout
[백준] 1008번 A/B (C++) 문제 https://www.acmicpc.net/problem/1008 1008번: A/B 두 정수 A와 B를 입력받은 다음, A/B를 출력하는 프로그램을 작성하시오. www.acmicpc.net 코드 way1 #include using namespace std; int main() { double a, b; cin >> a >> b; cout.precision(10); cout > a >> b; cout