結果

問題 No.222 引き算と足し算
ユーザー rf141rf141
提出日時 2015-06-28 17:46:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 564 bytes
コンパイル時間 2,974 ms
コンパイル使用メモリ 74,808 KB
実行使用メモリ 55,644 KB
最終ジャッジ日時 2024-04-27 17:43:38
合計ジャッジ時間 7,319 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
53,548 KB
testcase_01 AC 104 ms
53,628 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 105 ms
53,572 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 111 ms
53,892 KB
testcase_13 AC 95 ms
52,500 KB
testcase_14 AC 103 ms
53,676 KB
testcase_15 WA -
testcase_16 AC 106 ms
54,176 KB
testcase_17 WA -
testcase_18 AC 97 ms
52,504 KB
testcase_19 AC 103 ms
53,984 KB
testcase_20 AC 110 ms
53,760 KB
testcase_21 AC 92 ms
52,076 KB
testcase_22 AC 97 ms
53,040 KB
testcase_23 WA -
testcase_24 AC 95 ms
52,520 KB
testcase_25 WA -
testcase_26 AC 104 ms
53,996 KB
testcase_27 AC 92 ms
54,524 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 107 ms
53,800 KB
testcase_31 AC 93 ms
52,500 KB
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

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()));
	    
		if(get.indexOf("+") != -1){
			System.out.println(a-b);
		}
		if(get.indexOf("-") != -1){
			System.out.println(a+b);
		}
	}
}
0