0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

P1597 语句解析

https://www.luogu.com.cn/record/38654562
This commit is contained in:
Baoshuo Ren 2020-09-20 15:21:18 +08:00 committed by Baoshuo Ren
parent 2d5a4841a8
commit 21b545d685
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68
3 changed files with 80 additions and 0 deletions

74
problem/P1597/P1597.cpp Normal file
View File

@ -0,0 +1,74 @@
// https://www.luogu.com.cn/record/38654562
#include<bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
string s;
a = b = c = 0;
cin >> s;
for(int i = 0 ; i < s.size() ; i += 5) {
cout << s[i] << ' ' << s[i+3] << ' ';
switch(s[i]) {
case 'a':
if('0' <= s[i+3] && s[i+3] <= '9') {
a = s[i+3] - '0';
} else {
switch(s[i+3]) {
case 'a':
a = a;
break;
case 'b':
a = b;
break;
case 'c':
a = c;
break;
}
}
break;
case 'b':
if('0' <= s[i+3] && s[i+3] <= '9') {
b = s[i+3] - '0';
} else {
switch(s[i+3]) {
case 'a':
b = a;
break;
case 'b':
b = b;
break;
case 'c':
b = c;
break;
}
}
break;
case 'c':
if('0' <= s[i+3] && s[i+3] <= '9') {
c = s[i+3] - '0';
} else {
switch(s[i+3]) {
case 'a':
c = a;
break;
case 'b':
c = b;
break;
case 'c':
c = c;
break;
}
}
break;
}
cout << a << ' ' << b << ' ' << c << endl;
}
printf("%d %d %d\n", a, b, c);
return 0;
}

BIN
problem/P1597/data/P1597_2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
problem/P1597/data/P1597_2.out (Stored with Git LFS) Normal file

Binary file not shown.