Error: duplicate case label free pascal compiler

Error: duplicate case label free pascal compiler

我有错误"Error: duplicate case label",这是因为我使用的是免费的pascal编译器,我到处都找不到解决办法,你能给我一个吗,谢谢。

我会上传完整的代码以防万一我遗漏了什么。 不好意思弄乱了。

program diceroll;
uses crt;
var count,time,double,dice1,dice2:integer;
    sum1,sum2,sum3,sum4,sum5,sum6:integer;
    idk:boolean;

Function Is_Double(d1,d2:integer):boolean;
begin
if d1 = d2 then
    Is_Double:=true
else
    Is_Double:=false;

end;


begin
randomize;
clrscr;
writeln('How many times do you want to roll the dice');
writeln(' ');
readln(time);
double:=0;
sum1:=0;
sum2:=0;
sum3:=0;
sum4:=0;
sum5:=0;
sum6:=0;

repeat
    begin
    dice1:=random(6)+1;
    dice2:=random(6)+1;
    idk:=Is_Double(dice1,dice2);
    count:= count + 1;
    if (idk = true) then
        begin
            double:= double + 1;
            writeln(dice1,' ',dice2,' ','true');
        end
    else
        writeln(dice1,' ',dice2,' ','true');
    end;
    if idk=true then
        begin 
            case dice1 of
                1:sum1:=sum1+1;
                1:sum2:=sum2+1;
                1:sum3:=sum3+1;         
                1:sum4:=sum4+1;         
                1:sum5:=sum5+1;
                1:sum6:=sum6+1; 
        end;
until count = time;
writeln(double);
writeln(' ');
writeln(' ');
writeln(' ');
writeln(' ');
writeln('  Amount of doubles ');
writeln('1 2 3 4 5 6');
writeln(sum1,' ',sum2,' ',sum3,' ',sum4,' ',sum5,' ',sum6);
readln;
end.

谢谢

就在这里:

         case dice1 of
            1:sum1:=sum1+1;
            1:sum2:=sum2+1;
            1:sum3:=sum3+1;         
            1:sum4:=sum4+1;         
            1:sum5:=sum5+1;
            1:sum6:=sum6+1; 

应该是这样的:

           case dice1 of
                1:sum1:=sum1+1;
                2:sum2:=sum2+1;
                3:sum3:=sum3+1;         
                4:sum4:=sum4+1;         
                5:sum5:=sum5+1;
                6:sum6:=sum6+1; 

你的 BEGIN...END 结构在我看来也有问题:

repeat
// REPEAT doesn't need BEGIN 
    dice1:=random(6)+1;
    dice2:=random(6)+1;
    idk:=Is_Double(dice1,dice2);
    count:= count + 1;
    if (idk = true) then
        begin
            double:= double + 1;
            writeln(dice1,' ',dice2,' ','true');
        end
    else
        writeln(dice1,' ',dice2,' ','true');
// one extra END; removied - the one closing the unnecessory BEGIN at the start of REPEAT
    if idk=true then
        begin 
            case dice1 of
                1:sum1:=sum1+1;
                2:sum2:=sum2+1;
                3:sum3:=sum3+1;         
                4:sum4:=sum4+1;         
                5:sum5:=sum5+1;
                6:sum6:=sum6+1; 
            end;                     // CASE must have an END;
        end;
until count = time;