結果
| 問題 |
No.9001 標準入出力の練習問題(テスト用)
|
| ユーザー |
harurun
|
| 提出日時 | 2022-07-15 19:00:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 1,248 bytes |
| コンパイル時間 | 1,911 ms |
| コンパイル使用メモリ | 200,248 KB |
| 最終ジャッジ日時 | 2025-01-30 07:14:06 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
char c;
stack<int> s;
void mul(){
int a=s.top();s.pop();
int b=s.top();s.pop();
s.push(a*b);
}
void div(){
int a=s.top();s.pop();
int b=s.top();s.pop();
s.push(b/a);
}
void add(){
int a=s.top();s.pop();
int b=s.top();s.pop();
s.push(a+b);
}
void sub(){
int a=s.top();s.pop();
int b=s.top();s.pop();
s.push(b-a);
}
bool eq0(){
int a=s.top();
s.pop();
return a==0;
}
int main(){
s.push(0);
label1:
s.push(10);
mul();
c=getchar();
s.push(c);
s.push(s.top());
s.push(32);
sub();
if(eq0()){
goto label2;
}
s.push(48);
sub();
add();
goto label1;
label2:
s.pop();
s.push(10);
div();
s.push(0);
label3:
s.push(10);
mul();
c=getchar();
s.push(c);
s.push(s.top());
s.push(10);
sub();
if(eq0()){
goto label4;
}
s.push(48);
sub();
add();
goto label3;
label4:
s.pop();
s.push(10);
div();
add();
printf("%d",s.top());
s.pop();
s.push(32);
printf("%c",s.top());
label5:
c=getchar();
s.push(c);
s.push(s.top());
s.push(10);
sub();
if(eq0()){
goto label6;
}
printf("%c",s.top());
s.pop();
goto label5;
label6:
s.push(10);
printf("%c",s.top());
s.pop();
}
harurun