結果

問題 No.222 引き算と足し算
ユーザー rf141rf141
提出日時 2015-06-28 17:44:11
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 553 bytes
コンパイル時間 3,537 ms
コンパイル使用メモリ 79,500 KB
実行使用メモリ 55,980 KB
最終ジャッジ日時 2024-04-27 17:43:03
合計ジャッジ時間 7,652 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
41,224 KB
testcase_01 AC 88 ms
39,808 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 102 ms
41,052 KB
testcase_15 WA -
testcase_16 AC 102 ms
41,208 KB
testcase_17 WA -
testcase_18 AC 108 ms
41,296 KB
testcase_19 AC 93 ms
39,872 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 103 ms
41,380 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

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 = 0; i<get.length(); i++){
			if(!Character.isDigit(get.charAt(i))){
					count = i;
			}
		}
	    
	    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