|
|
back to boardProblem by compiler types??? :( I wrote this program on Pascal and AC!: var m1:array[0..150000] of longint; m2:array[0..150000] of byte; i,n:longint; k:byte; begin readln(n); for i:=1 to n do readln(m1[i],m2[i]); for k:=100 downto 0 do begin for i:=1 to n do if m2[i]=k then writeln(m1[i],' ',m2[i]); end; end. Then i wrote same program on C++: #include <iostream.h> void main() { long int m1[150000]; unsigned char m2[150000]; long int i,n; char k; cin>>n; for (i=1;i<=n;i++) cin>>m1[i]>>m2[i]; for (k=100;k>=0;k--){ for (i=1;i<=n;i++){ if (m2[i]==k) cout<<m1[i]<<" "<<m2[i]<<"\n"; } } } C++ program gives WA on #4 Please help me... Re: Problem by compiler types??? :( I had the same problem. The problem is in unsigned char. Idon't know why, but if I change unsigned chsr to short int test 4 is passed, but it's Memory Limit on 11 test Re: Problem by compiler types??? :( Posted by KAV 4 May 2006 21:54 If to scan numbers with scanf("%d",&c) instead of cin - it will be OK. And with cin you need to call operator>>(istream&,int&) manually. IMHO :) |
|
|