๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm ๐Ÿง‘๐Ÿป‍๐Ÿ’ป/๋ฐฑ์ค€(BOJ)

[๋ฐฑ์ค€,c++] 13420๋ฒˆ - ์‚ฌ์น™์—ฐ์‚ฐ

by dkswnkk 2021. 11. 4.
 

13420๋ฒˆ: ์‚ฌ์น™์—ฐ์‚ฐ

์‚ฌ์น™์—ฐ์‚ฐ์€ ๋ง์…ˆ, ๋บ„์…ˆ, ๊ณฑ์…ˆ, ๋‚˜๋ˆ—์…ˆ์œผ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์œผ๋ฉฐ, ์ปดํ“จํ„ฐ ํ”„๋กœ๊ทธ๋žจ์—์„œ ์ด๋ฅผ ํ‘œํ˜„ํ•˜๋Š” ๊ธฐํ˜ธ๋Š” +, -, *, / ์™€ ๊ฐ™๋‹ค. ์•„๋ž˜๋Š” ์ปดํ“จํ„ฐ ํ”„๋กœ๊ทธ๋žจ์—์„œ ํ‘œํ˜„ํ•œ ์‚ฌ์น™ ์—ฐ์‚ฐ์˜ ์˜ˆ์ œ์ด๋‹ค. 3 * 2 = 6 ๋ฌธ

www.acmicpc.net

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {

    long long int T; scanf("%lld", &T);

    for (int i = 0; i < T; i++) {
        long long int num1, num2, result;
        char cacul, equal;
        scanf("%lld %c %lld %c %lld", &num1, &cacul, &num2, &equal, &result);


        if (cacul == '+') {
            if (num1 + num2 == result) printf("correct\n");
            else printf("wrong answer\n");

        }
        else if (cacul == '-') {
            if (num1 - num2 == result) printf("correct\n");
            else printf("wrong answer\n");

        }
        else if (cacul == '*') {
            if (num1 * num2 == result) printf("correct\n");
            else printf("wrong answer\n");

        }
        else if (cacul == '/') {
            if (num1 / num2 == result) printf("correct\n");
            else printf("wrong answer\n");

        }

    }

}

๋Œ“๊ธ€