M
M
Mushkiter0072017-09-19 20:24:28
Delphi
Mushkiter007, 2017-09-19 20:24:28

How can I make this simple code work?

I need all the variables listed to remain integers and fractional ones to remain fractional.
I understand that Pascal swears that the Integer variable is assigned an expression in which there are Real variables?
Question: How can I just write this expression into an Integer variable? Or is it impossible without changing anything in the variables?
Error: Incompatible types: 'integer' and 'Extended'

var
  M,N,M1,M2,M3,x:integer;
  N1,N2,N3:real;

  for M1:=0 to trunc(N/MAX) do
    begin
      M2:=(N-M1*N1-M*N3+M1*N3);
      if ((M2 mod 9 = 0) and (M2>=0)) then
        begin
          M3:=M-M1-(M2 div 9);
          if(M3>=0) then
            begin
               ...........
      end;
    end;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mushkiter007, 2017-09-19
@Mushkiter007

You'll have to think more. Solution found, thanks for such extensive help. A piece of code is from an Olympiad problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question