⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.~pas

📁 字符出现的次数 字符出现的次数
💻 ~PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


function   GetNum(stra,str:string):integer;//eg.       stra='A';str:='ABCABC';
  var     
      i,j:integer;   
  begin   
        j:=0;   
        result:=0;
        for   i:=1   to   length(str)   do   begin   
                if   strcomp(pchar(stra), pchar(copy(str,i,1)) )=0   then   
                      j:=j+1;   
        end;   
        result:=j;   
  end;



  function   StrCount(const   Sub:   string;   Str:   string):   Integer;   
  var   
      nPos:   Integer;   
  begin   
      Result   :=   0;   
      nPos   :=   Pos(Sub,   Str);   
      while   nPos   >   0   do   
      begin   
          Inc(Result);   
          Delete(Str,   1,   nPos   +   Length(Sub)   -   1);   
          nPos   :=   Pos(Sub,   Str);   
      end;   
  end;



procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text:= inttostr( StrCount(edit1.Text , memo1.Text)    );
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -