|
|
вернуться в форумWA #1 I don't understand why WA #1 because I fully tested answer of mu programm and answer on site. They hasn't got differences! Even invisible characters. Here is my code: var n,i,j,fl,k,n1:longint; a,b,d,x:string; y,z:array [1..100] of string; z1:array [1..100] of byte; c:char; begin readln (n); for i:=1 to n do begin fl:=0; a:=''; b:=''; d:=''; readln (x); n1:=length (x); j:=0; repeat j:=j+1; If x[j]<>' ' then a:=a+x[j]; until x[j]=' '; repeat j:=j+1; If x[j]<>' ' then b:=b+x[j]; until x[j]=' '; repeat j:=j+1; If x[j]<>' ' then d:=d+x[j]; until j>=n1; fl:=0; If a='register' then begin for j:=1 to k do If b=y[j] then fl:=1; If fl=1 then writeln ('fail: user already exists') else begin writeln ('success: new user added'); k:=k+1; y[k]:=b; z[k]:=d; z1[k]:=0;end;end; fl:=0; If a='login' then begin for j:=1 to k do If b=y[j] then fl:=j; If fl=0 then writeln ('fail: no such user') else If (fl>0) and (d<>z[fl]) then writeln ('fail: incorrect password') else If (fl>0) and (d=z[fl]) and (z1[fl]=1) then writeln ('fail: already logged in') else begin writeln ('success: user logged in'); z1[fl]:=1;end;end; fl:=0; If a='logout' then begin for j:=1 to k do If b=y[j] then fl:=j; If fl=0 then writeln ('fail: no such user') else If (fl>0) and (z1[fl]=0) then writeln ('fail: already logged out') else begin writeln ('success: user logged out'); z1[fl]:=0;end;end;end; end. |
|
|