老生常谈,非 void 函数无返回值会 RE
by xsmfollower @ 2024-04-10 19:37:40
@[xsmfollower](/user/1308728) yes,you are _**intelligent**_
by Max__universe @ 2024-04-10 19:39:42
@[xsmfollower](/user/1308728) 怎么返回捏?
by lucy2012 @ 2024-04-10 19:39:53
@[lucy2012](/user/1252442)
```cpp
#include<bits/stdc++.h>
using namespace std;
string un_chinese(){
string s="",sum;
char c;
int num;
while(cin>>c){
if(c=='['){
cin>>num;
sum=un_chinese();
while(num--)
s+=sum;
}
else if(c==']')
return s;
else s+=c;
}
return s;
}
int main(){
cout<<un_chinese();
return 0;
}
by Dream_Creator @ 2024-04-10 19:40:26
@[lucy2012](/user/1252442) 6,怎么返回你不会?
by Max__universe @ 2024-04-10 19:40:31
@[Max__universe](/user/1295142) 所以?
by xsmfollower @ 2024-04-10 19:41:17
@[lucy2012](/user/1252442) `return s;` 不就好了吗
by xsmfollower @ 2024-04-10 19:41:33
只需要在函数末尾+```
return s
```
就行
by Max__universe @ 2024-04-10 19:41:57
@[xsmfollower](/user/1308728) 怎么?
by Max__universe @ 2024-04-10 19:43:00
@[xsmfollower](/user/1308728) @[Max__universe](/user/1295142) @[Dream_Creator](/user/529722) 好吧,第一次遇到,谢谢啦!
by lucy2012 @ 2024-04-10 19:45:14