入门题都不会写了是不是可以爬了
查看原帖
入门题都不会写了是不是可以爬了
558597
LV06摸鱼楼主2022/1/10 17:51
#include<bits/stdc++.h>
using namespace std;
string a;
bool b;
int main(){
while(1){
a=getchar();
if(a=="{") cout<<"{"<<endl;
else if(a!="}"&& a!=","&& b!=1) {cout<<"  "<<a;b=1;}
else if(a!="}"&& a!=",") cout<<a;
else if(a!="}") {cout<<a<<endl;b=0;}
else {cout<<endl<<"}";break;}
}
}

我知道忘了判断大括号中大括号但实在不会写了

下面判断代码0分...

#include<bits/stdc++.h>
using namespace std;
string a;
int f;
bool b,c,d,e;
int main(){
while(1){
a=getchar();
if(a=="{"&&c!=1) {cout<<"{"<<endl;c=1;d=1;}
else if(c==1&&a=="{"){cout<<"  "<<"{"<<endl;d=1;e=1;f+=2;}
else if(a!="}"&& a!=","&& b!=1&&e==1) {
for(int i=0;i<f;i++){
cout<<"  ";
b=1;d=0;
}
cout<<a;
}
else if(a!="}"&& a!=","&& b!=1) {cout<<"  "<<a;b=1;d=0;}
else if(a!="}"&& a!=",") {cout<<a;d=0;}
else if(a!="}") {cout<<a<<endl;b=0;d=0;}
else if(c!=1){cout<<endl<<"}";break;}
else if(d==1){cout<<"  "<<"}";c=0;f=1;}
else {cout<<endl<<"  "<<"}";c=0;f=1;}
}
}

求求大佬了QAQ

2022/1/10 17:51
加载中...