33,027
社区成员




#include <STDIO.H>
#define type int
#define MAX 1024
int main(int argc, char **argv)
{
type arr[MAX];
int i;
for ( i=0;i<MAX;++i ) {
arr[i] = i;
}
type* from = new type[MAX];
type* to = new type[MAX];
/*
static type from[MAX];
static type to[MAX];
*/
int top=0;
while ( scanf("%d", &i) ) {
printf("arr[%d] = %d\n", i, arr[i]);
if ( top>from[i] && to[ from[i] ]==i ) {
printf("访问过\n");
} else {
from[i] = top;
// printf("from[%d] = %d\n", i, from[i]);
to[from[i]] = i;
// printf("to[%d] = %d\n", i, to[from[i]]);
++top;
}
}
return 0;
}