結果

問題 No.49 算数の宿題
ユーザー kekuremakekurema
提出日時 2019-03-21 09:40:47
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 749 bytes
コンパイル時間 2,851 ms
コンパイル使用メモリ 99,988 KB
実行使用メモリ 22,708 KB
最終ジャッジ日時 2023-08-24 17:41:47
合計ジャッジ時間 4,117 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
20,624 KB
testcase_01 AC 54 ms
20,640 KB
testcase_02 AC 55 ms
22,708 KB
testcase_03 AC 55 ms
20,644 KB
testcase_04 AC 55 ms
20,608 KB
testcase_05 AC 55 ms
20,844 KB
testcase_06 AC 54 ms
18,808 KB
testcase_07 AC 55 ms
20,752 KB
testcase_08 AC 55 ms
22,704 KB
testcase_09 AC 54 ms
20,792 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Code
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            line += "e";
            int sum = 0;
            int num = 0;
            char ope = '*';
            foreach(var c in line)
            {
                if (c == '*' || c == '+' || c == 'e') {
                    if (ope == '*') sum += num;
                    else sum *= num;
                    num = 0;
                    ope = c; 
                }
                else num = num * 10 + int.Parse("" + c);
            }

            Console.WriteLine(sum);
        }
    }
}
0