結果

問題 No.222 引き算と足し算
ユーザー rf141
提出日時 2015-06-28 17:44:11
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 553 bytes
コンパイル時間 3,630 ms
コンパイル使用メモリ 74,668 KB
実行使用メモリ 54,396 KB
最終ジャッジ日時 2024-11-15 21:56:45
合計ジャッジ時間 9,299 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 5 WA * 2 RE * 24
権限があれば一括ダウンロードができます

ソースコード

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