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:为什么会output limit exceed?In Reply To:为什么会output limit Posted by:anonym11 at 2004-10-12 16:05:50 代码如下: #include<iostream> #include<cstring> using namespace std; struct book { char title[100]; char author[100]; int b; int r; }bk[500],t; int main() { char temp[300],cmd[10],title[100]; int i,j,p= 0,first; while(1) { gets(temp); if(strcmp(temp,"END") == 0) break; for(i = 1,j = 0;temp[i] - '"';i ++,j ++) bk[p].title[j] = temp[i]; bk[p].title[i-1] = '\0'; for(i += 5,j = 0;temp[i] ;i ++,j ++) bk[p].author[j] = temp[i]; bk[p].author[j] = '\0'; cout << bk[p].author << ' ' << bk[p].title << endl; bk[p].b = bk[p].r = 0; p ++; } for(i = p-1;i > 0;i --) for(j = 0;j < i;j ++) if(strcmp(bk[j].author,bk[j+1].author) > 0 || (strcmp(bk[j].author,bk[j+1].author) == 0 && strcmp(bk[j].title ,bk[j+1].title ) > 0)) { t = bk[j];bk[j] = bk[j+1];bk[j+1] = t; } while(1){ gets(temp) ; if(strcmp(temp,"END") == 0) break; for(i = 0;i < 6;i ++) cmd[i] = temp[i]; cmd[i] = '\0'; if(cmd[0] == 'B') { for(i = 8,j = 0;temp[i+1] ;i ++,j ++) title[j] = temp[i] ; title[j] = '\0'; for(i = 0;i < p;i ++) if(strcmp(bk[i].title ,title) == 0) { bk[i].b = 1; break; } } else if(cmd[0] == 'R') { for(i = 8,j = 0;temp[i+1] ;i ++,j ++) title[j] = temp[i] ; title[j] = '\0'; for(i = 0;i < p;i ++) if(strcmp(bk[i].title ,title) == 0) { bk[i].b = 0;bk[i].r = 1; break; } } else if(cmd[0] == 'S') for(i = 0,first = 1;i < p;i ++) { if(bk[i].r == 1 ) if(first) printf("Put \"%s\" first\n",bk[i].title); else printf("Put \"%s\" after \"%s\"\n",bk[i].title,title); if(!bk[i].b) { strcpy(title,bk[i].title); first = 0; } } } cout << "END" << endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator