| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1875 人关注过本帖
标题:[求助]全局变量问题
只看楼主 加入收藏
xiaomao13056
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-7-24
收藏
 问题点数:0 回复次数:4 
[求助]全局变量问题

我是新手,要求是输入几个数,然后小到大排列输出;
unit Unit1;

interface

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

type
TForm1 = class(TForm)
Label1: TLabel;
dataedit: TEdit;
input: TButton;
datalist: TListBox;
sort: TButton;
close: TButton;
procedure inputClick(Sender: TObject);
procedure sortClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;


implementation

{$R *.dfm}

begin
type
queue=array[1..10] of integer;
procedure sort1(var queue1:queue;n:integer);
procedure swap(var x,y:integer);
var
form1:TForm1;
i:integer;
dataarray:queue;
procedure sort1(var queue1:queue;n:integer);
var k,j:integer;
flag:boolean;
begin
for k:=1 to n-1 do
begin
flag:=true;
for j:=1 to n-k do
if queue1[j]>queue1[j+1] then
begin
flag:=false;
swap(queue1[j],queue1[j+1]);
end;
if flag then
exit;
end;
end;
procedure swap(var x,y:integer);
var temp:integer;
begin
temp:=x;
x:=y;
y:=temp;
end;
procedure TForm1.inputClick(Sender: TObject);
begin
i:=i+1;
dataarray[i]:=strtoint(dataedit.Text);
datalist.Items.Add(dataedit.Text);
dataedit.Text:='';
dataedit.setfocus;
end;

procedure TForm1.sortClick(Sender: TObject);
var j:integer;
begin
lblresult.caption:='这组数从小到大排列为:'+chr(13);
sort1(dataarray,i);
for j:=1 to i do
lblresult.Caption:=lblresult.caption+' '+inttostr(dataarray[j]);
i:=0;
end;

end.

编译后提示:
[Error] Unit1.pas(38): Statement expected but 'TYPE' found
[Error] Unit1.pas(70): ';' expected but '.' found
[Error] Unit1.pas(73): Undeclared identifier: 'dataedit'
[Error] Unit1.pas(73): '(' expected but ')' found
[Error] Unit1.pas(74): Missing operator or semicolon
[Error] Unit1.pas(74): Missing operator or semicolon
[Error] Unit1.pas(74): Missing operator or semicolon
[Error] Unit1.pas(75): Missing operator or semicolon
[Error] Unit1.pas(75): '(' expected but ':=' found
[Error] Unit1.pas(76): Missing operator or semicolon
[Error] Unit1.pas(79): Identifier redeclared: 'TForm1'
[Error] Unit1.pas(82): Undeclared identifier: 'lblresult'
[Error] Unit1.pas(85): Missing operator or semicolon
[Error] Unit1.pas(85): Missing operator or semicolon
[Error] Unit1.pas(89): ';' expected but '.' found
[Error] Unit1.pas(91): Declaration expected but end of file found
[Error] Unit1.pas(19): Unsatisfied forward or external declaration: 'TForm1.inputClick'
[Error] Unit1.pas(20): Unsatisfied forward or external declaration: 'TForm1.sortClick'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
书上说在interface部分声明类型标识queue,过程sort1和swap,以及2个全局变量i和dataarray.
但我不知道输在哪.在前面interface报了好多错

搜索更多相关主题的帖子: 变量 全局 Sender TButton procedure 
2007-07-24 23:16
nongen
Rank: 5Rank: 5
来 自:网络
等 级:贵宾
威 望:17
帖 子:322
专家分:0
注 册:2006-11-25
收藏
得分:0 
begin//这行多余
type
queue=array[1..10] of integer;
procedure sort1(var queue1:queue;n:integer);
procedure swap(var x,y:integer);
var
form1:TForm1;
i:integer;
dataarray:queue;
其它的逐步调试看看。

昨天不是我的,明天不是你的,今天却是我们的。
http://www.
2007-07-25 09:03
xiaomao13056
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-7-24
收藏
得分:0 
回复:(nongen)begin//这行多余type queue=array[1...

谢谢,不过还是不行呀~,
[Error] Unit1.pas(69): ';' expected but '.' found
[Error] Unit1.pas(72): Undeclared identifier: 'dataedit'
[Error] Unit1.pas(72): '(' expected but ')' found
[Error] Unit1.pas(73): Missing operator or semicolon
[Error] Unit1.pas(73): Missing operator or semicolon
[Error] Unit1.pas(73): Missing operator or semicolon
[Error] Unit1.pas(74): Missing operator or semicolon
[Error] Unit1.pas(74): '(' expected but ':=' found
[Error] Unit1.pas(75): Missing operator or semicolon
[Error] Unit1.pas(78): Identifier redeclared: 'TForm1'
[Error] Unit1.pas(81): Undeclared identifier: 'lblresult'
[Error] Unit1.pas(84): Missing operator or semicolon
[Error] Unit1.pas(84): Missing operator or semicolon
[Error] Unit1.pas(88): ';' expected but '.' found
[Error] Unit1.pas(90): Declaration expected but end of file found
[Error] Unit1.pas(19): Unsatisfied forward or external declaration: 'TForm1.inputClick'
[Error] Unit1.pas(20): Unsatisfied forward or external declaration: 'TForm1.sortClick'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

2007-07-25 11:06
xiaomao13056
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-7-24
收藏
得分:0 
回复:(xiaomao13056)回复:(nongen)begin//这行多...
???????????????
2007-07-25 15:41
nongen
Rank: 5Rank: 5
来 自:网络
等 级:贵宾
威 望:17
帖 子:322
专家分:0
注 册:2006-11-25
收藏
得分:0 
for k:=1 to n-1 do
begin
flag:=true;
for j:=1 to n-k do
if queue1[j]>queue1[j+1] then
begin
flag:=false;
swap(queue1[j],queue1[j+1]);
end;
if flag then
exit;
end;
end;//你删了前面的 begin,却没把这个对应的end 删 掉。

昨天不是我的,明天不是你的,今天却是我们的。
http://www.
2007-08-18 23:26
快速回复:[求助]全局变量问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020829 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved