Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
纪念一下 真是波折啊!#include <stdio.h> #include <string.h> #include <ctype.h> void mange(char b[],char a[],int n,int m,int level) { int i=0,j; for(;n<=m;n++) { if(a[n]!=' ') { break; } } for(;n<=m;n++) { b[i++]=a[n]; } b[i]='\0'; } int suojin(int l,int n,int m,int level,char str1[]) { for(;l<n;l++) { if(str1[l]=='{') { level+=4; } } for(;n<=m;n++) { if(str1[n]=='}') { level-=4; } } return level; } int main() { char str1[20000]; char str2[20000]; char str3[2000][400]; int level=0; int i,j=0; int m=0,n=0,l=0; int hang; int kong[10000]; gets(str1); while(gets(str2)!=NULL) { strcat(str1,str2); } for(i=0;i<strlen(str1);i++) { if(str1[i]=='{'||str1[i]==';') { m=i; level=suojin(l,n,m,level,str1); kong[j]=level; mange(str3[j],str1,n,m,level); j++; l=n; n=m+1; } } hang=j; for(i=0;i<hang;i++) { for(j=0;j<kong[i];j++) { printf(" "); } for(j=0;j<strlen(str3[i]);j++) { if(isspace(str3[i][j])) { str3[i][j]==0; } else { if(str3[i][j]=='{'&&i!=0) { printf(" "); } printf("%c",str3[i][j]); if(str3[i][j]==',') { printf(" "); } } } printf("\n"); } printf("}\n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator