본문 바로가기

백준/C46

백준 10951번 : A+B - 4 [C] 주소 : https://www.acmicpc.net/problem/10951 10951번: A+B - 4 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net 소스 : #define _CRT_SECURE_NO_WARNINGS #include int main() { int a, b = 0; while(scanf("%d %d", &a, &b) != EOF ) { printf("%d\n", a + b); } return 0; } 마무리 : 이 문제는 입력을 하고 계산을 한 뒤 출력을 하는 것이 지속적으로 해야하는 것이다. 즉 종료의 조건이 없는 것이다. 종료를 하려면 강제종료를 해야하는데 EOF(파일의 끝을 표현 || 상수로 -1값을 지칭)를 이용하여 강제종.. 2022. 7. 16.
백준 10950번 : A+B - 3 [C] 주소 : https://www.acmicpc.net/problem/10950 10950번: A+B - 3 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net 소스 : #define _CRT_SECURE_NO_WARNINGS #include int main() { int size = 0; int a, b = 0; scanf("%d", &size); for (int i = 0;i 2022. 7. 13.
백준 10871번 : X보다 작은 수 [C] 주소 : https://www.acmicpc.net/problem/10871 10871번: X보다 작은 수 첫째 줄에 N과 X가 주어진다. (1 ≤ N, X ≤ 10,000) 둘째 줄에 수열 A를 이루는 정수 N개가 주어진다. 주어지는 정수는 모두 1보다 크거나 같고, 10,000보다 작거나 같은 정수이다. www.acmicpc.net 소스 : #define _CRT_SECURE_NO_WARNINGS #include int main() { int size,sta = 0; int array[10001] = { 0, }; scanf("%d %d", &size, &sta); for (int i = 0;i 2022. 7. 13.
백준 10869번 : 사칙연산 [C] 주소 : https://www.acmicpc.net/problem/10869 10869번: 사칙연산 두 자연수 A와 B가 주어진다. 이때, A+B, A-B, A*B, A/B(몫), A%B(나머지)를 출력하는 프로그램을 작성하시오. www.acmicpc.net 소스 : #define _CRT_SECURE_NO_WARNINGS #include int main() { int a, b = 0; scanf("%d %d", &a, &b); printf("%d\n",a+b); printf("%d\n",a-b); printf("%d\n",a*b); printf("%d\n",a/b); printf("%d",a%b); return 0; } 마무리 : 이 문제는 두 개의 수를 입력받고 계산만 해주면 된다. 2022. 7. 13.