結果
| 問題 |
No.222 引き算と足し算
|
| コンテスト | |
| ユーザー |
@abcde
|
| 提出日時 | 2019-03-02 22:45:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 353 bytes |
| コンパイル時間 | 1,289 ms |
| コンパイル使用メモリ | 157,520 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 13:01:34 |
| 合計ジャッジ時間 | 2,553 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:13: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
17 | cout << ans << endl;
| ^~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
// 1. 入力情報取得.
int x, y;
char op;
cin >> x >> op >> y;
// 2. アリスのルールで足し算, 引き算する.
int ans;
if(op == '-') ans = x + y;
if(op == '+') ans = x - y;
// 3. 出力.
cout << ans << endl;
return 0;
}
@abcde