목록Programming/C (47)
Information Security Study
두 값이 입력되어야 하고 입력된 모든 값을 더하면 되는 문제이다. #include int main() { int t; int a; int b; scanf("%d", &t); for(int i = 0; i < t; i++) { scanf("%d %d", &a, &b); printf("%d\n", a + b); } return 0; } for문으로 입력된 모든 값을 계산해 출력할 수 있도록 작성했다.
구구단을 출력하는 문제이다. 입출력 예시이다. #include int main() { int a; scanf("%d", &a); for(int i = 1; i
3개 주사위의 눈에 따라 상금을 계산하는 문제이다. if 문으로 계산하면 된다. 입출력 예시이다. #include int main() { int a; int b; int c; scanf("%d %d %d", &a, &b, &c); if(a == b && b == c) { printf("%d", a * 1000 + 10000); } else if(a == b && a != c) { printf("%d", a * 100 + 1000); } else if(b == c && b != a) { printf("%d", b * 100 + 1000); } else if(a == c && a != b) { printf("%d", a * 100 + 1000); } else if(a > b && a > c) { printf..
요리 시작 시각에 소요 시간을 더한 시각을 출력하면 될 것 같다. 입출력 예제이다. #include int main() { int A; int B; int C; scanf("%d %d", &A, &B); scanf("%d", &C); A += C / 60; B += C % 60; if(B >= 60) { A += 1; B -= 60; } if(A >= 24){ A = A % 24; } printf("%d %d", A, B); return 0; } 입력 받은 시간을 더한 뒤의 시각이 24시가 넘어가지 않도록 나머지 연산자를 사용했다.
입력된 시간보다 45분 이른 시간이 출력되면 된다. #include int main() { int H; int M; scanf("%d %d", &H, &M); // 45분 이상인 경우 if(H >= 0 && H = 45 && M 0 && H = 0 && M
시험 점수를 입력해 성적을 출력하는 문제이다. 입출력 예제이다. #include int main() { int score; scanf("%d", &score); if(score >= 90 && score = 80 && score = 70 && score = 60 && score
두 수를 비교하는 프로그램을 작성하는 문제이다. 입출력 예시이다. 두 수의 비교 결과를 출력하면 된다. #include int main() { int a; int b; scanf("%d %d", &a, &b); if(a == b) { printf("=="); } else if(a > b) { printf(">"); } else { printf("