結果

問題 No.222 引き算と足し算
ユーザー kuramu
提出日時 2016-02-11 09:37:05
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 900 bytes
コンパイル時間 2,442 ms
コンパイル使用メモリ 74,836 KB
実行使用メモリ 50,564 KB
最終ジャッジ日時 2024-11-15 22:09:59
合計ジャッジ時間 5,217 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 RE * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.*;
public class Main {

	 public static void main(String[] args) {
	      BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in));
	      try {
	    	  String line = stdReader.readLine();
	    	  if(line.charAt(0)=='+'){
	    		  line = line.substring(1,line.length());
	    	  }
	    	  Pattern pattern = Pattern.compile("\\+");
	    	  Matcher matcher = pattern.matcher(line);
	    	  if(matcher.find()){
	    		  String[] temps = line.split("\\+");
	    		  System.out.println(Integer.parseInt(temps[0])-Integer.parseInt(temps[1]));
	    	  }else{
	    		  String[] temps = line.split("\\-");
	    		  System.out.println(Integer.parseInt(temps[0])+Integer.parseInt(temps[1]));
	    	  }
	      } catch (IOException e) {
			e.printStackTrace();
	      }
	}
}
0