和标准答案一样。
但是while(cin>>c)导致我在控制台一直输入字符不停下来。请问这时要怎么调试?
#include<iostream>
using namespace std;
string expand() {
string res = "", x;
char c;int times=0;
while (cin >> c) {
if (c == '[') {
cin >> times;
x = expand();
for (int i = 0;i < times;i++) res += x;
}
else if (c == ']') return res;
else res += c;
}
return res;
}
int main() {
cout << expand();
return 0;
}