回 帖 发 新 帖 刷新版面

主题:请求高手帮助

下面的代码 为何测试不能通过 请求高手帮助 谢谢!

Program ruin;
    {[A+,T=3]Instruction to PasMat.}

    Uses
      Dos;

    Type
      String80=String[80];

    Var
      Name:String80;
      Infile,Outfile:Text;
      C22,NSet,NSetL,Index:LongInt;
      BoundLower,BoundUpper,Cap,Capital,Del,
        Probability,ProbabilityWin,ProbablityLose,
        TradeWin,TradeLose:Extended;
        Hour,Minute,Sec,Sec100,Year,Month,Day,
         DayOfWeek:Word;

      Begin
        Write('Input file name:');
        ReadLn(Name);
        Assign(Infile,Name);
        Reset(Infile);
        Write('Output file name:');

      ReadLn(Name);
      Assign(Outfile,Name);
      Rewrite(Outfile);
      Randomize;
      WriteLn;
      Repeat
        GetTime(Hour,Minute,Sec,Sec100);
        GetDate(Year,Month,Day,DayOfWeek);
        ReadLn(Infile,Name);
        WriteLn(Outfile,Name);
        ReadLn(Infile,Capital,TradeWin,TradeLose,NSetL);
        WriteLn(Outfile);
        WriteLn(Outfile,'Probability of Win Probability of Ruin');
        Del :=0.05:
        ProbabilityWin :=0.00;
        BoundLower :=0.0;
        BoundUpper :=100 * Capital;
        For Index :=0 to 17 do
          Begin
            ProbabilityWin :=ProbabilityWin + Del;
            NSet :=0;
            C22 :=0;
            Repeat
              Cap :=Capital;
              Inc(NSet);
              If(NSet / 10= NSet Div 10) then
                Write(^M,'Iteration Number',
                     (Nset + (Index * NsetL)) :1,'of',
                     (18*NSetL):1);
              Repeat
                Probability:=Random;
                  {random between 0 and 1}
                If(Probability <=ProbabilityWin) then
                   Cap:=Cap+TradeWin
                else
                   Begin
                      Cap:=Cap+TradeLose;
                      If(Cap<=0) then
                        Inc(C22)
                      End

              Until((Cap>=BoundUpper)
                    or(Cap<=BoundLower))
            Until(NSet>=NSetL);
            ProbabilityLose:=C22/NSet;
            WriteLn(Outfile,'     ',ProbabilityWin:10:8,
                    '        ',ProbabilityLose:10:8)
            End
          WriteLn;
          WriteLn;
          WriteLn(Outfile);
          WriteLn('Starting at',Hour:2,':',Minute:2,
                  ':',Sec:2,'on',Month:2,'/',
                  Day,'/',Year);
          WriteLn(Outfile,'Starting at',Hour:2,':',Minute:2,':',Sec:
                 2,'on',Month:2,'/',Day,'/',Year);
          GetTime(Hour,Minute,Sec,Sec100);
          GetDate(Year,Month,Day,DayOfWeek);
          WriteLn('Ending at',Hour:2,':',Minute:2,
                  ':',Sec:2,'on',Month:2,'/',
                  Day,'/',Year);
          WriteLn;
          WriteLn(Outfile,'Ending at',Hour:2,':',
                  Minute:2,':',Sec:2,'on',Month:2,
                  '/',Day,'/',Year)
          WriteLn(Outfile);
        Until Eof(Infile);
        Close(Infile);
        Close(Outfile);
     End.

回复列表 (共1个回复)

沙发

40行 Del :=0.05:
最后应改为分号

71行有个未定义的标识符ProbabilityLose

86行漏了个分号

92行又漏了个分号

我来回复

您尚未登录,请登录后再回复。点此登录或注册