結果

問題 No.222 引き算と足し算
ユーザー kuramukuramu
提出日時 2016-02-11 10:05:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 49 ms / 1,000 ms
コード長 1,032 bytes
コンパイル時間 1,706 ms
コンパイル使用メモリ 77,644 KB
実行使用メモリ 50,220 KB
最終ジャッジ日時 2024-04-27 17:51:45
合計ジャッジ時間 4,088 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
49,688 KB
testcase_01 AC 46 ms
49,888 KB
testcase_02 AC 46 ms
50,144 KB
testcase_03 AC 47 ms
49,844 KB
testcase_04 AC 47 ms
49,980 KB
testcase_05 AC 46 ms
49,808 KB
testcase_06 AC 45 ms
49,832 KB
testcase_07 AC 46 ms
50,156 KB
testcase_08 AC 45 ms
50,052 KB
testcase_09 AC 46 ms
50,012 KB
testcase_10 AC 46 ms
49,888 KB
testcase_11 AC 46 ms
49,812 KB
testcase_12 AC 49 ms
50,052 KB
testcase_13 AC 48 ms
50,180 KB
testcase_14 AC 48 ms
50,220 KB
testcase_15 AC 46 ms
50,020 KB
testcase_16 AC 46 ms
49,896 KB
testcase_17 AC 44 ms
36,888 KB
testcase_18 AC 42 ms
36,472 KB
testcase_19 AC 42 ms
36,608 KB
testcase_20 AC 44 ms
36,904 KB
testcase_21 AC 43 ms
36,472 KB
testcase_22 AC 42 ms
36,728 KB
testcase_23 AC 43 ms
36,716 KB
testcase_24 AC 41 ms
36,872 KB
testcase_25 AC 42 ms
36,776 KB
testcase_26 AC 43 ms
36,744 KB
testcase_27 AC 41 ms
36,776 KB
testcase_28 AC 42 ms
36,928 KB
testcase_29 AC 44 ms
36,668 KB
testcase_30 AC 43 ms
36,860 KB
testcase_31 AC 42 ms
36,804 KB
testcase_32 AC 42 ms
36,804 KB
testcase_33 AC 42 ms
36,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	 public static void main(String[] args) {
	      BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in));
	      try {
	    	  String line = stdReader.readLine();
	    	  String op = "";
	    	  int a = 0;
	    	  int b = 0;
	    	  for(int i=1;i<line.length();i++){
	    		  if(line.charAt(i)=='+'){
	    			  op = "+";
	    			  a = Integer.parseInt(line.substring(0,i));
	    			  b = Integer.parseInt(line.substring(i+1,line.length()));
	    			  break;
	    		  }else if(line.charAt(i)=='-'){
	    			  op = "-";
	    			  a = Integer.parseInt(line.substring(0,i));
	    			  b = Integer.parseInt(line.substring(i+1,line.length()));
	    			  break;
	    		  }
	    	  }	    	  
	    	  if(op.equals("+")){
	    		  System.out.println(a-b);
	    	  }else if(op.equals("-")){
	    		  System.out.println(a+b);
	    	  }
	      } catch (IOException e) {
			e.printStackTrace();
	      }
	}
}
0