這明顯用Tries就可以輕鬆完成, 可是我卻卡在讀取那邊...
int n, cnt;
int i, j, tmp;
char c[];
int s[];
while ( scanf ( "%d", &n ) != EOF )
{
memset ( s, 0, xxxxxx*sizeof(int) );
cnt = 0;
for ( i = 0; i < n; i++ )
{
scanf ( "%s", c );
tmp = 0;
for ( j = 0; j < 4; j++ )
if ( )
{
printf ( "New! %d\n", );
}
else printf ( "Old! %d\n", );
};
};
奇怪的是我將同樣的code轉成pascal就過了, 這讓我非常苦惱...
var i, j, n, tmp, cnt : longint;
s : array [ 0 .. xxxxxx ] of longint;
c : string;
begin
while not eof do
begin
readln ( n );
cnt := 0;
fillchar ( s, xxxxxx*sizeof(longint), 0 );
for i := 1 to n do
begin
readln ( c );
tmp := 0;
for j := 1 to 4 do
if ( ) then
begin
writeln ( 'New! ',);
end
else writeln ( 'Old! ', );
end;
end;
end.
想請教一下我C++的code哪裡出問題了? 謝謝