zoukankan      html  css  js  c++  java
  • 52张牌随意发

    uses
      SysUtils,Classes;

    type
      CardType=array[0..3] of string;
      const CardNums=12;
    type
      RCardrecord=record
        CardInfo: string;
      end;
      PCard=^RCardrecord;

    var
      slist: TList;
      i,j: Integer;
      iSub,iSpare: Integer;
      sCardType,sCardNum: string;
      aCard: PCard;
      iRandom,iCount: Integer;
      tCardInfo: string;
      aCardType: CardType;
    begin
      try
        { TODO -oUser -cConsole Main : Insert code here }
        aCardType[0]:='S';
        aCardType[1]:='H';
        aCardType[2]:='D';
        aCardType[3]:='C';

        slist := TList.Create;
        for i := 1 to 52 do
        begin
          iSub:=i div 14;
          iSpare:=i mod 14;
          sCardType := aCardType[iSub];
          sCardNum := IntToHex(iSpare,1);
          New(aCard);
          aCard.CardInfo := sCardType+sCardNum;
          slist.Add(aCard);
        end;

        Randomize;
        for j := 0 to 3 do
        begin
          tCardInfo := '';
          for i := 1 to CardNums do
          begin
            iRandom:=Random(slist.Count);
            aCard:=slist.Items[iRandom];
            tCardInfo := tCardInfo + ' ' + aCard^.CardInfo;

            slist.Delete(iRandom);
            Dispose(aCard);
          end;
          Writeln(tCardInfo);
        end;

        iCount:=slist.Count;
        for i := iCount-1 downto 0 do
        begin
          aCard:=slist.Items[i];
          slist.Delete(i);
          Dispose(aCard);
        end;
        slist.Free;
        Readln(i);
      except
        on E:Exception do
          Writeln(E.Classname, ': ', E.Message);
      end;
    end.

  • 相关阅读:
    深入理解网卡配置bond的意义和作用
    关于B站UP主墨茶official逝世的感想
    Python内置函数学习笔记
    Python学习笔记(4)
    测试工作中不可忽略的点
    Python学习笔记(3)
    Python学习笔记(2)
    Python学习笔记(1)
    docker-compose部署
    Xtrabackup源码安装
  • 原文地址:https://www.cnblogs.com/batman425/p/3257747.html
Copyright © 2011-2022 走看看