Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- void printEspacos(int quant) {
- cout << endl;
- for(int i = 0; i < quant*4; i++)
- cout << '.';
- }
- int main(){
- string str;
- while(!cin.eof()) {
- getline(cin,str);
- if(str[0] == '#') cout << str << endl;
- else {
- int chaves = 0, pv = 0;
- bool isFor=false,isString=false;
- for(int i = 0; i < str.size(); i++) {
- if(isString){
- cout<< str[i];
- if(str[i] == '"') isString = false;
- }
- else{
- switch(str[i]) {
- case '"':
- cout << '"';
- isString = true;
- break;
- case '{':
- printEspacos(chaves);
- chaves++;
- cout <<'{';
- printEspacos(chaves);
- isFor =false;
- break;
- case ';':
- cout << ';';
- if(!isFor){
- if(str[i+1] != '}')printEspacos(chaves);
- }
- break;
- case 'f':
- if(str[i+1] == 'o' && str[i+2] == 'r' && str[i+3] == ')')isFor = true;
- cout << 'f';
- break;
- case '}':
- chaves--;
- printEspacos(chaves);
- cout <<'}';
- if(str[i+1] != '}')printEspacos(chaves);
- break;
- default:
- cout << str[i];
- break;
- }
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement