它会跳过每当我打印列表中的第一输出,如何纠正呢?

问题描述 投票:0回答:1

每当我尝试与第一进入5名名为合格人员的信息打印选民(输出)的列表的a,b,c,d和e和其他5不符合命名F,G,H,I,J。它输出B,C,d,E,F作为有效选民当它应该是A,B,C,d,电子

PROGRAM List_of_Eligible_Voters;
{States whether a person is a valid voter or not}


Const
YOE=2019;


VAR
Felony_Status: string;
Eligibility:ARRAY[1..10] of string;
Name:ARRAY[1..10] OF string;
YOB,Age:integer;
Count:integer;
i:integer;




BEGIN
i:=0;
Count:=0;

     FOR i:= 1 TO 10 DO
     Begin

          Name[i]:='Name';
          Eligibility[i]:='Eligibility';
     End;

          Writeln('Please enter the name of the person.');
          Readln (Name[Count]);
          Writeln ('Please enter the year of birth of the person.');
          Readln (YOB);
          Writeln ('Have the person ever been convicted of a felony?()Answer with yes/no.');
          Readln (Felony_Status);
          While (YOB <> 0) AND (Count<=10) Do
           begin
                Age:= YOE-YOB;
                IF (Age>= 18) AND (Felony_Status = 'no')Then

                   Eligibility[Count]:= 'yes'
                ELSE

                   Eligibility[Count]:= 'no';

                   Writeln('Please enter the name of the person.');
                   Readln (Name[Count]);
                   Writeln ('Please enter the year of birth of the person.');
                   Readln (YOB);
                   Writeln ('Have the person ever been convicted of a felony?()Answer with yes/no.');
                   Readln (Felony_Status);
                   COUNT:=COUNT+1;
          END;
                 Writeln ('List of Eligible Candidates');
                 FOR i:= 1 TO Count DO
                     begin
                     IF  Eligibility[i]= 'yes' THEN
                         Writeln (Name[i], '()is eligible to vote.');

                     END;
                         readln;
END.
freepascal
1个回答
3
投票

看起来你写的时候读取时,使用计数作为指数(I),那么指数作为索引。计数是基于0和基于索引为1。您是否尝试同步两个呢?

© www.soinside.com 2019 - 2024. All rights reserved.