PersonalCorpus 版 (精华区)

Your C++ program has solved Ok the problem 245 (Uncompress)
in 1.780 seconds using as much as 1392 kbytes of virtual memory.
Congratulations!

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <ctype.h>


void main()
{
#ifndef ONLINE_JUDGE
    freopen("c:\\uva\\input245.txt","r",stdin);
    freopen("c:\\uva\\output245.txt","w",stdout);
#endif

    char ch;

    char word[20000][51],now[51];
    int i,j,k,tw=0;

    k=0;
    while (1) {
        ch=getchar();
        if (isalnum(ch)) {
            now[k]=ch;
            k++;
            continue;
        } else {
            now[k]=0; k=0;
            if (isdigit(now[0])) {
                sscanf(now,"%d",&i);
                if (i==0) break;
                strcpy(word[tw],word[tw-i]);
                for (j=tw-i;j<tw;j++) strcpy(word[j],word[j+1]);
                printf("%s",word[tw]);
            } else if (now[0]!=0) {
                strcpy(word[tw],now); tw++;
                printf("%s",now);
            }
            putchar(ch);
        }
    }
}
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.314毫秒