PersonalCorpus 版 (精华区)
寄信人: sino (茶水)
标 题: 482
发信站: 哈工大紫丁香 (2002年06月16日19:09:31 星期天)
来 源: 202.118.239.224
Your C++ program has solved Ok the problem 482 (Permutation Arrays)
in 5.330 seconds using as much as 768 kbytes of virtual memory.
#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\\input482.txt","r",stdin);
freopen("c:\\uva\\output482.txt","w",stdout);
#endif
char f[10000][14],ff[10000][14];
int a[10000];
int i,j,k,n,tot;
char s[60000];
scanf("%d\n",&n);
while (n>0) {
n--;
gets(s);
i=0; k=0;
while (k<strlen(s)) {
while ((k<strlen(s))&&(s[k]==' ')) k++;
if (k<strlen(s)) {
sscanf(s+k,"%d",&a[i]);
i++;
}
while ((k<strlen(s))&&(s[k]!=' ')) k++;
}
tot=i;
gets(s);
i=0; k=0;
while (k<strlen(s)) {
while ((k<strlen(s))&&(s[k]==' ')) k++;
if (k<strlen(s)) {
sscanf(s+k,"%s",&f[i]);
i++;
}
while ((k<strlen(s))&&(s[k]!=' ')) k++;
}
for (i=0;i<tot;i++) strcpy(ff[a[i]-1],f[i]);
for (i=0;i<tot;i++) printf("%s\n",ff[i]);
if (n>0) printf("\n");
gets(s);
}
}
--
SecureNetTerm can be dowloaded to all countries except
Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria.
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.239.224]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.198毫秒