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 |
高手帮我看看挖,为什么是RE啊#include <iostream> #include <string> using namespace std; char c[100][8]; char temp[8]; char f[100][8]; int countfile=0; char space[]="| "; int compare(const void *elem1,const void *elem2){ return (strcmp((char*)elem1,(char*)elem2)); } void output(){ int n=0,i=-1; printf("ROOT\n"); while(c[++i][0]!='*'){ if(c[i][0]=='d') n++; if(c[i][0]==']'){ n--; continue; } for(int p=0;p<n;p++) printf("%s",space); printf("%s\n",c[i]); } qsort(f,countfile,8,compare); i=-1; while(f[++i][0]!='*') printf("%s\n",f[i]); } int main() { int i=0,n=0,j=0,k=0; int count=0; scanf("%s",temp); while(temp[0]!='#'){ if(temp[0]=='d') n++; if(temp[0]==']'){ strcpy(c[k++],temp); n--; } else if(temp[0]=='f'&&n==0){ strcpy(f[j++],temp); countfile++; } else strcpy(c[k++],temp); while(temp[0]=='*'){ strcpy(f[j++],temp); printf("DATA SET %d:\n",++count); output(); n=0;k=0;j=0;countfile=0; break; } scanf("%s",temp); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator