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 |
【求助】如何减小使用的内存,如何减小运行时间?如题。 看到很多人都是0毫秒,内存也都在35K以下。很是羡慕。 以下是我的代码。如何改进? // AC 152K 16MS #include <stdio.h> #include <string.h> int main() { char stack[200][71]; char cmd[8]; int current = 0, top = 0; strcpy(stack[0], "http://www.acm.org/"); while (scanf("%s", cmd)) { if (!strcmp("QUIT", cmd)) break; if (!strcmp("VISIT", cmd)) { top = ++current; scanf("%s", stack[current]); } else if (!strcmp("BACK", cmd)) { if (--current < 0) { puts("Ignored"); ++current; continue; } } else if (!strcmp("FORWARD", cmd)) { if (++current > top) { puts("Ignored"); --current; continue; } } printf("%s\n", stack[current]); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator