求助,麻烦大佬帮忙看看这有哪里不对...

P1597 语句解析

@[yuyuyuyu12345](/user/324176) 有没有一种可能赋值语句不止3个
by lxc_awa @ 2022-08-29 08:40:48


@[yuyuyuyu12345](/user/324176) 而且也可以赋值成一个变量
by lxc_awa @ 2022-08-29 08:54:51


@[luxiaochi123](/user/626785) 大佬,我改成这样啦,麻烦您再帮我看一下.... ``` #include <iostream> #include <cstring> #include <string> #include <algorithm> using namespace std; int cnt; int main() { string a; cin>>a; int n=a.size(); int c[20]; for(int i=0;i<n;i++) { if(a[i]==';') { if(a[i-1]-'0'<=9&&a[i-1]-'0'>=0) cout<<a[i-1]-'0'<<" "; else cout<<"0 "; } }} ```
by yuyuyuyu12345 @ 2022-08-29 15:11:38


@[yuyuyuyu12345](/user/324176) 额,我也不是dalao虽然能改出来,但有点长,都是重复的,试过了能ac ```cpp #include <iostream> #include <cstring> #include <string> #include <algorithm> using namespace std; int cnt; int main() { char a1='0',a2='0',a3='0'; string a; cin>>a; int n=a.size(); int c[20]; for(int i=0;i<n;i++) { if(a[i]==';') { if(a[i-1]-'0'<=9&&a[i-1]-'0'>=0) { if(a[i-4]=='a') { a1=a[i-1]; } if(a[i-4]=='b') { a2=a[i-1]; } if(a[i-4]=='c') { a3=a[i-1]; } } else if(a[i-1]=='a') { if(a[i-4]=='a') { a1=a1; } if(a[i-4]=='b') { a2=a1; } if(a[i-4]=='c') { a3=a1; } } else if(a[i-1]=='b') { if(a[i-4]=='a') { a1=a2; } if(a[i-4]=='b') { a2=a2; } if(a[i-4]=='c') { a3=a2; } } else if(a[i-1]=='c') { if(a[i-4]=='a') { a1=a3; } if(a[i-4]=='b') { a2=a3; } if(a[i-4]=='c') { a3=a3; } } }} cout<<a1<<' '<<a2<<' '<<a3<<endl; return 0; } ```
by lxc_awa @ 2022-08-29 16:16:03


@[yuyuyuyu12345](/user/324176) 这题不能直接输出,可能有多个赋值语句比如: a:=3;b:=4;c:=5;a:=6;按你的代码来就是3 4 5 6应该是6 4 5;
by lxc_awa @ 2022-08-29 16:20:32


@[luxiaochi123](/user/626785) 喔~懂啦,谢谢大佬,终于明白啦~
by yuyuyuyu12345 @ 2022-08-29 16:35:51


@[yuyuyuyu12345](/user/324176) 求互关
by lxc_awa @ 2022-08-29 16:38:05


@[luxiaochi123](/user/626785) 好嘞,来啦
by yuyuyuyu12345 @ 2022-08-29 16:52:10


```cpp #include<bits/stdc++.h> using namespace std; int r1=1,r2=1;string a; int x,y,z,la; int main() { cin>>a;la=a.size()-1;x=y=z=0; for(int i=0;i<=la;i++) { if(i%5==0) { if(a[i]=='a') { if(a[i+3]=='b') { x=y; } else if(a[3+i]=='c') { x=z; } else if(a[3+i]=='a') { } else { x=int(a[i+3]-48); } } if(a[i]=='b') { if(a[i+3]=='a') { y=x; } else if(a[3+i]=='c') { y=z; } else if(a[3+i]=='b') { } else { y=int(a[i+3]-48); } } if(a[i]=='c') { if(a[i+3]=='b') { z=y; } else if(a[3+i]=='c') { } else if(a[3+i]=='a') { z=x; } else { z=int(a[i+3]-48); } } } } printf("%d %d %d",x,y,z); return 0; }
by xingcode @ 2022-11-27 15:09:03


|