Recent

Author Topic: exit code 201  (Read 7887 times)

ransaked

  • New member
  • *
  • Posts: 10
exit code 201
« on: November 25, 2015, 02:13:36 pm »
Hello world!
I'm new to FPC and Lazarus community.

So I have a question that I can't answer for a time. It may sound stupid but what does 'exit code 201' mean?
I post my answers for questions to a site (campion.edu.ro) and when it runs the program no problems detected and I have max points 4 the answer but when I do the same thing on my computer it compiles the program successfuly but when running sends exit code 201. I don't know where the mistake is but I know it's smth with the loop(when I delete the loop problem disappear).

Here is my input file/program code(the files too if needed): 
                                                                         Input:
12343
2002
4002
3003
                                                                      Program:
type t=array[1..1000] of longint;
var a,b:t;
 n,i,c:integer;
 s:longint;
 m,g:text;
begin
 assign(m,'bancomat.in');
 reset(m);
 readln(m,s);
 readln(m,n);
for i:=1 to n do
 read(m,a);
 close(m);

for i:=1 to n do
 begin
  c:=a mod 10;
  if c=2 then
   s:=s+(a div 10) else
    if c=3 then
     if s>(a div 10) then
      s:=s-(a div 10);
  end;
 assign(g,'bancomat.out');
 rewrite(g);
 writeln(g,s);
 close(g);
end.
                          Thanks a lot for time spent with my stupid question looking for a nice answer.
                                                              Have a nice day. :) :) :)

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: exit code 201
« Reply #1 on: November 25, 2015, 03:48:00 pm »
http://www.freepascal.org/docs-html/user/userap4.html

Quote
201 Range check error

You need to add the number of your line data (i.e. variable "n") into your input file 'bancomat.in'.

Something like (for n=3):
Code: [Select]
12343
3
2002
4002
3003

And also to modify your code (I can't see how you can compile it without any errors, anyway). Note the "a"  -----> "a [ i ] ":

Code: Pascal  [Select]
  1. type t=array[1..1000] of longint;
  2. var a,b:t;
  3.  n,i,c:integer;
  4.  s:longint;
  5.  m,g:text;
  6. begin
  7.  assign(m,'bancomat.in');
  8.  reset(m);
  9.  readln(m,s);
  10.  readln(m,n);
  11. for i:=1 to n do
  12.  read(m,a[i]);
  13.  close(m);
  14.  
  15. for i:=1 to n do
  16.  begin
  17.   c:=a[i] mod 10;
  18.   if c=2 then
  19.    s:=s+(a[i] div 10) else
  20.     if c=3 then
  21.      if s>(a[i] div 10) then
  22.       s:=s-(a[i] div 10);
  23.   end;
  24.  assign(g,'bancomat.out');
  25.  rewrite(g);
  26.  writeln(g,s);
  27.  close(g);
  28. end.

ransaked

  • New member
  • *
  • Posts: 10
Re: exit code 201
« Reply #2 on: November 25, 2015, 04:05:30 pm »
Thx man.

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: exit code 201
« Reply #3 on: November 25, 2015, 08:32:15 pm »
It seems I've forgotten the most important in my former post:

Welcome in this new community.