PASCAL WHY WA1??

Posted by

phloyd 5 Nov 2018 20:59

Am I stupid or what?

code seems to be working

var x,a,b:integer;

function sum(x:integer): INTEGER;

var s:integer;

begin

while x>0 do

begin

s:=s+x mod 10;

x:=x div 10;

end;

sum:=s;

end;

begin

read (x);

a:=x div 1000;

b:=x mod 1000;

if (sum(a)=sum(b+1)) or (sum(a)=sum(b-1)) then writeln ('Yes')

else writeln ('No');

end.