主题:本人初学DELPHI,向大侠们请教一下
很简单的把一字符串中的非元音字母颠倒,然后再全部颠倒一次,可我不知道哪里错了,总运行不出来,我真的不知道到底哪错了,谁能帮我看看么?谢谢!!真的非常感谢~~~!!!!
程序源文件我如下,谁能帮我解决一下我真的很很很感谢!!-
unit mima;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
const
stacksize=1000;
type
elementype=char;
stack=class
top:word;
element:array[1..stacksize] of elementype;
constructor init;
destructor done;
function isempty:boolean;
function isfull :boolean;
procedure push(item:elementype);
procedure pop (var item:elementype);
end;
procedure pp;
var
Form1: TForm1;
astack:stack;
bstack:stack;
m:integer; //输入的字符串长度
str1:string; // 输出
str:string; //EDIT。TEXT内容
implementation
{$R *.dfm}
constructor stack.init;
begin
top:=0;
end;
destructor stack.done;
begin
end;
function stack.isempty:boolean;
begin
isempty:=top=0
end;
function stack.isfull:boolean;
begin
isfull:=top=stacksize;
end;
procedure stack.push(item:elementype);
begin
top:=top+1;
element[top]:=item;
end;
procedure stack.pop(var item:elementype);
begin
item:=element[top];
top:=top-1
end;
procedure pp;
var
it,p:char;
i:integer;
begin
astack.init;
bstack.init;
for i:=1 to m do
astack.push(str[i]);
while (not astack.isempty) do
begin
astack.pop(p);
if (p<>'a') and(p<>'e') and (p<>'i')and (p<>'o') and (p<>'u') then
bstack.push(p)
else
begin
while not bstack.isempty do
begin
bstack.pop(it);
str1:=str1+it;
end;
str1:=str1+p;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
str1:=' ';
pp;
memo1.Lines.add(str1);
end;
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=VK_RETURN then
str:=Edit1.text;
m:=length(str);
end;
end.
程序源文件我如下,谁能帮我解决一下我真的很很很感谢!!-
unit mima;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
const
stacksize=1000;
type
elementype=char;
stack=class
top:word;
element:array[1..stacksize] of elementype;
constructor init;
destructor done;
function isempty:boolean;
function isfull :boolean;
procedure push(item:elementype);
procedure pop (var item:elementype);
end;
procedure pp;
var
Form1: TForm1;
astack:stack;
bstack:stack;
m:integer; //输入的字符串长度
str1:string; // 输出
str:string; //EDIT。TEXT内容
implementation
{$R *.dfm}
constructor stack.init;
begin
top:=0;
end;
destructor stack.done;
begin
end;
function stack.isempty:boolean;
begin
isempty:=top=0
end;
function stack.isfull:boolean;
begin
isfull:=top=stacksize;
end;
procedure stack.push(item:elementype);
begin
top:=top+1;
element[top]:=item;
end;
procedure stack.pop(var item:elementype);
begin
item:=element[top];
top:=top-1
end;
procedure pp;
var
it,p:char;
i:integer;
begin
astack.init;
bstack.init;
for i:=1 to m do
astack.push(str[i]);
while (not astack.isempty) do
begin
astack.pop(p);
if (p<>'a') and(p<>'e') and (p<>'i')and (p<>'o') and (p<>'u') then
bstack.push(p)
else
begin
while not bstack.isempty do
begin
bstack.pop(it);
str1:=str1+it;
end;
str1:=str1+p;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
str1:=' ';
pp;
memo1.Lines.add(str1);
end;
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=VK_RETURN then
str:=Edit1.text;
m:=length(str);
end;
end.