結果

問題 No.222 引き算と足し算
ユーザー rf141rf141
提出日時 2015-06-28 17:50:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 1,000 ms
コード長 510 bytes
コンパイル時間 2,772 ms
コンパイル使用メモリ 75,240 KB
実行使用メモリ 54,272 KB
最終ジャッジ日時 2024-04-27 17:43:46
合計ジャッジ時間 7,216 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
53,596 KB
testcase_01 AC 102 ms
53,632 KB
testcase_02 AC 103 ms
53,672 KB
testcase_03 AC 93 ms
52,560 KB
testcase_04 AC 104 ms
53,636 KB
testcase_05 AC 98 ms
52,584 KB
testcase_06 AC 105 ms
53,544 KB
testcase_07 AC 98 ms
53,164 KB
testcase_08 AC 95 ms
52,536 KB
testcase_09 AC 92 ms
52,268 KB
testcase_10 AC 106 ms
53,940 KB
testcase_11 AC 108 ms
53,664 KB
testcase_12 AC 104 ms
54,052 KB
testcase_13 AC 98 ms
54,272 KB
testcase_14 AC 109 ms
54,080 KB
testcase_15 AC 108 ms
54,108 KB
testcase_16 AC 106 ms
52,912 KB
testcase_17 AC 103 ms
54,104 KB
testcase_18 AC 115 ms
53,664 KB
testcase_19 AC 111 ms
54,108 KB
testcase_20 AC 124 ms
53,864 KB
testcase_21 AC 113 ms
53,632 KB
testcase_22 AC 104 ms
53,788 KB
testcase_23 AC 89 ms
52,460 KB
testcase_24 AC 107 ms
54,000 KB
testcase_25 AC 103 ms
53,776 KB
testcase_26 AC 99 ms
52,472 KB
testcase_27 AC 99 ms
52,744 KB
testcase_28 AC 102 ms
53,644 KB
testcase_29 AC 106 ms
53,632 KB
testcase_30 AC 107 ms
53,944 KB
testcase_31 AC 106 ms
53,916 KB
testcase_32 AC 103 ms
53,944 KB
testcase_33 AC 97 ms
52,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class CalcPlusMinus {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String get = scan.next();
		int count = 0;
		
	    for(int i = 1; i<get.length(); i++){
			if(!Character.isDigit(get.charAt(i))){
					count = i;
					break;
			}
		}
	    
	    int a = Integer.parseInt(get.substring(0,count));
	    int b = Integer.parseInt(get.substring(count+1, get.length()));
	    
		System.out.println(
				(get.charAt(count)=='+')?(a-b):(a+b)
				);
	}
}
0