填空题[说明] 已知一棵二叉树用二叉链表存储,t指向根节点,P指向树中任一节点。下列算法为输出从t到P之问路径上的节点。 [C程序] #define MaxSize 1000 typedef struct node TelemType data ; struct node *ichiid,*rchiid; BiNode,*BiTree; void Path(BiTree t,BiNode *P) BiTree *stack[Maxsize],*stackl[Maxsize],*q; int tag[Maxsize],top=0,topl; q=t; /*通过先序遍历发现P*/ dowhile(q!=NULL &&q!=p) /*扫描左孩子,_日.相应的节点不为P*/ (1) ; stack[top]=q; tag[top]=0; (2) ; if(top>0) if(stack[top]=P) break; /*找到P,栈底到栈顶为t到P*/ if(tag[top]==1)top--; else q=stack[top]; q=q->rchiid; tag[top]=1; (3) ; top--;topl=0; while(top>0) q=stack[top]; /*反向打印准备*/ topl++; (4) ; top--; while( (5) ) /*打印栈的内容*/ q=stackl[topl]j printf(q->data); topl--;
填空题[说明] 这个是一个链接存储线性表的直接插入排序函数。把未排序序列中的第一个结点插到已排序序列中。排序完毕,链表中的结点按结点值由小到大链接。 [函数] typedef struct node char data; struct node *link; NODE; NODE *insert_sort (NODE *h) NODE *t,*s,*u,*v; s=h->link; h->link=NULL: while(s!=NULL) for(t=s,v=h;v!=NULL && V->data<t->data; (1) , (2) ); s=s->link; if(V==h) (3) ; else (4) ; (5) ; return h;
填空题[说明] 本程序实现对指定文件内的单词进行计数。其中使用二叉树结构来保存已经读入的不同单词,并对相同单词出现的次数进行计数。此二叉树的左孩子结点的字符串值小于父结点的字符串值,右孩子结点的字符串值大于父结点的字符串值。函数getword(char *filename,char*word)是从指定的文件中得到单词。char* strdup(char* s)是复制s所指向的字符串,并返回复制字符串的地址。 [函数] #include <stdio. h> #include<ctype. h> #include <string.h> #define MAXWORD 100 struct node char *word; int count; struct node *left; struct node *right; struct node *addtree(struct node *p,char *w) int cond; if (p==NULL) /*向树中插入结点*/ p=(struct node*) malloc(sizeof(struct node)); p->word=strdup (w); p->count=1; (1) ; else if((cond=strcmp (w,p->word))==0) (2) ; else if (cond<0) p->left= (3) ; else p->right= (4) ; return p; main() struct node *root; char word [MAXWORD]; root=NULL; filename="example .dat"; while getword(filename,word)! =EOF root= (5) ;
填空题阅读以下说明和C++程序,将应填入 (n) 处的字句写在对应栏内 [说明] 以下程序的功能是计算三角形、矩形和正方形的面积并输出。 程序由4个类组成:类Triangle,Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述三种图形面积的通用接口。 [C++程序] #include<iostream.h> #include<math.h> class Figure public: virtual double getArea()=0; //纯虚拟函数 ; class Rectangle: (1) protected: double height; double width; public: Rectangle(); Rectangle(double height,double width) This->height=height; This->width=width; double getarea() return (2) ; ; class Square: (3) public: square(double width) (4) ; ; class triangle: (5) double la; double lb; double lc; public: triangle(double la,double lb,double lc) this->la=la;thiS->ib;this->lc; double getArea() double s=(la+lb+lc)/2.0; return sqrt(s*(s-la)**(s-lb)*(s-lc)); ; viod main() figure*figures[3]= new triangle(2,3,3),new Rectangle(5,8),new Square(5); for(int i=0; i<3;i++) cout<<"figures["<<i<<"]area="<<(figures)->getarea()<<endl; ;
填空题【说明】 以下程序的功能是计算三角形、矩形和正方形的面积并输出。 程序由4个类组成:类Triangle、Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述3种图形面积的通用接口。 【C++程序】 #include<iostream.h> #include<math.h> class Figure public: virtual double getArea()=0; //纯虚拟函数 ; class Rectangle: (1) protected: double height; double width; public: Rectangle() ; Rectangle(double height,double width) this->height=height; this->width=width; double getArea() return (2) ; ; class Square: (3) public: Square(double width) (4) ; ; class Triangle: (5) double la; double lb; double lc; Public: Triangle(double la, double lb, double lc) This->la=la; this->lb=lb; this->lc=lc; double getArea() double s = (la+lb+±c)/2.0; return sqrt(s,(s-la)*(s-lb)*(s-Ic)); ; void main() Figure*figures[3]= new Triangle(2,3,3), new Rectangle(5,8), new SqUare(5)); for(int i=0;i<3;i++) cout<<"figures["<<i<<"]area="<<(figures[i])->getArea()<<endl;
填空题[说明]已知包含头结点(不存储元素)的单链表元素已经按照非递减方式排序,函数compress(NODE*head)的功能是去掉其中重复的元素,使得链表中的元素互不相同。在处理过程中,当元素重复出现时,保留元素第1次出现时所在的结点。图8-4(a)、(b)是经函数compress()处理前后的链表结构示例图。链表的结点类型定义如下。typedefstructNodeintdata;structNode*next;NODE;[C语言函数]voidcompress(NODE*head)NODE*ptr,*q,*s,*t;ptr=head->next;/*取得第一个元素结点的指针*/while(ptrwhile(qs=(3);ptr->next=q;/*保留重复序列的第一个结点,将其余结点从链表中删除*/while(sfree(s);s=t;(5)=ptr->next;/*endofwhile*//*endofcompress*/
填空题【说明】某学校举办了一场奥运知识竞赛,参加竞赛的选手为200名,1~200为选手编号。竞赛时间为9:00~11:00。8道竞赛题目依次从“A”~“H”编号,选手可按任意次序答题,每完成一道题目,可立即提交答案。若答案正确(Y),则选择其他题目进行解答,否则,可继续做该题目或选择其他题目进行解答,直至竞赛结束。选手提交答案的情况及判定结果由专人即时录入,录入数据包括提交答案的时间、选手编号、题目编号(A~H)、是否正确(Y/N)等。对竞赛情况进行统计和排名的规则如下:1.若选手X在竞赛时提交的题目P解答正确,则解答该题目所用时间计算如下:解答题目P的用时=提交题目P正确的时间-竞赛的开始时间+罚时,罚时=提交题目P错误解答的次数×20例如:表1中14号选手在10:27提交了题目A的正确解答,因此该选手正确解答该题目所用时间P为87分钟,由于他在09:37和09:52两次提交了题目A的错误解答,因此罚时为(2×20)分钟=40分钟,所以14号选手解答题目A的用时=(87+40)分钟:127分钟。2.已经提交正确答案的题目再次提交时不再计算。3.竞赛结束时,选手的总用时为所有解答正确的题目用时累加所得,解答不正确的题目不计时。4.排名时,完成题目数量多者排名靠前;若完成的题目数相同,则用时少者排名靠前;若完成的题目数和所用时间均相等,则名次相同;完成题目数为。的选手不参加排名。本应用程序的运行窗口如图3所示。窗口中的两个文本框为Txt_time和Txt_player,分别用于录入提交答案的时间和选手编号。组合列表框Combo1提供题目编号(A~H),录入时从中选择。检查框Chk_yn用于输入解答是否正确信息。当单击“确定”按钮(Cmd_comfirm)时,录入的提交信息加入列表框List1中,排名情况在列表框List2输出。单击“关闭”按钮时退出应用程序。在开发过程中,需要编写的部分程序代码如下:【程序】PrivateTypeinfoNoAsInteger′选手编号NumAsInteger′完成题目数量TimeAsInteger′完成题目的总用时d(8)AsInteger′d用于记录提交第i个题目错误答案的次数a(8)AsBoolean′a用于记录第i个题目是否已经提交正确答案EndTypeDimR(201)Asinfo′R[j]用于统计编号为j的选手提交答案的情况DimMaxlndexAsInteger′Maxlndex记录提交答案的选手中编号最大者PrivateSubForm_Load()Fori=1to8Combo1.Addltemchr({{U}}(1){{/U}})NextCombo1.Text=Combo1.List(0):txt_time.Text="":txt_player.Text=""Fori=1To200R(i)num=0:R(i).time=0:R(i).no=iForj=1To8R(i).d(j)=0:R(i).a(j)=FalseNextj,iEndSubPrivateSubcmd_confirm_Click()Dimh,m,k,timeAsInteger,ch,pass,s1AsStringK=Instr(txt_time,text,":"):Ifk<2ThenGotoerror1H=Val(Left(txt_time.Text,k-1)):m=Val(Mid(txt_time.Text,k+1))Ifh>11Orh=11Andm>0Orm>=60ThengotoerrorlTime={{U}}(2){{/U}}′计算答题时间,以分钟为单位Iftxt_plater,text<1ortxt_player,text>200ThenGotoerrorl ch={{U}}(3){{/U}}pass=IIf(chk_yn.{{U}}(4){{/U}}=0,"N","Y")s1=txt_time.Text+Space(4)+txt_player.Texts1=s1+Space(10-Len(txt_player.Text))+ch+Space(8)+passList1.Additems1K=Val(txt_player.Text)′k为选手编号R(k).no=k′编号为k的选手的提交信息记录在下标为k的数组′元素中Ifk>maxindexThenmaxindex=k M=Asc(ch)-Asc("a")Ifpass<>"Y"Then′编号为k的选手提交第m个题目的解答不正确R(k).d(m)=R(k).d(m)+1ElseIfR(k).a(m)<>TrueThen′已经提交正确的题目的解答不再计算R(k).a(m)=true:R(k).num=R(k).num+1R(k).time=R(k).time+{{U}}(5){{/U}}Callstatistic′调用过程statistic进行实时排名和输出EndIfExitSuberror1:MsgBox"录入信息有错误!",vbOKOnlyEndSub
填空题[说明] 本程序将利用文本框txtInput 输入的一行字符串中的所有字母加密,加密,加密结果在文本txtCode中显示。加密方法如下:将每个字母的序号移动5个位置,即“A”->“F”“a”->“f”,“B”->“G”……“Y”->“D”,“Z”->“E”。程序段如下: [Visual Basic 代码]Private Sub Form_ Click() Dim strInput As String*70 ; 输入字符串 Dim Code as String*70 ;加密结果 Dim strTemp As String*1 ;当前处理的字符 Dim i as Integer Dim Length As Integer ;字符串长度 Dim iAsc As Integer ;第i个字ASCII码 (1) ;取字符串 i=1 Code=“” (2) ;去掉字符串右边的空格,求真正的长度Do While(i<=Length) (3) ;取第i个字符 If (strTemp>="A" And strTemp<="Z',) Then iAsc= Asc (strTemp)+5 If iAsc>Asc(“Z”)Then iAsc=iAsc-26 Code=Left$(Code,i-1)+Chr$ (iAsc) ElseIf (strTemp>="a" And strTemp<="z") Then iAsc=Asc(strTemp)+5 If iAsc>Asc (“z”) TheniAsc=iAsc-26 Code=Left$(Code,i-1)+Chr$(iAsc) Else Code=Left$(Code,i-1)+strTemp End If (4) Loop (5) ;显示加密结果End Sub
填空题【说明】 在窗体上画一个名称为Combo1的组合框,画两个名称分别Labe11、Labe12及Caption属性分别为“城市名称”和空白的标签。程序运行后,当在组合框中输入一个新项后按回车键 (ASCII码为13)时,如果输入的项在组合框的列表中不存在,则自动添加到组合框的列表中,并在Labe12中给出提示“已成功添加输入项”;如果存在,则在Labe12中给出提示“输入项已在组合框中”。 【程序】 Private Sub Combo1 (1) (KeyAscii As Integer) If KeyAscii= (2) Then For i=0 To (3) If Combo1. Text= (4) Then Labe12. Caption ="输入项已在组合框中" Exit Sub End If Next i Label2. Caption ="已成功添加输入项" Combo1. (5) Combo1.Text End If End Sub
填空题【说明】
下面的程序中定义了两个方法求自然数1~100的和。具体如下:int suml(int n);利用循环求1~n的和,int sum2(int n);利用递归方法求和1~n的和;在main()方法中调用这两个方法求1~100的和并显示。在程序的每条横线处填写一个适当的语句,使程序的功能完整。
public class Sum {
public static void main{{U}} (1) {{/U}}
{
//1. 调用sum1(int n),求1~100的和
//标准输出
{{U}} (2) {{/U}}("1~100的和:" +sum1(100));
//2. 调用sum2(int n),求1~100的和
//标准输出
{{U}} (2) {{/U}}("1~100的和:"+sum2(100));
}
static iht sum1( int n)
{
int result=0;
for(int i=1;i<=n;i++)
{{U}} (3) {{/U}}
retrun result;
}
static int sum2(int n)
{
if{{U}} (4) {{/U}}
return 1
else
{{U}} (5) {{/U}}
}
}
填空题[说明] 下而程序实现十进制向其他进制的转换。 [C++程序] #include"ioStream.h" #include"math.h" #include <conio.h> typedef struct node int data; node *next; Node; class Transform public: void Trans(int d,int i); //d为数字;i为进制 void print(); private: Node *top; ; void Transform::Trans(int d,int i) int m,n=0; Node *P; while(d>0) (1) ; d=d/i; p=new Node; if(!n) P->data=m; (2) j (3) ; n++; else p->data=m; (4) ; (5) ; void Transform::print() Node *P; while(top!=NULL) p=top; if(P->data>9) cout<<data+55: else cout<<data; top=p->next; delete P;
填空题【说明】
以下程序实现了利用鼠标任意移动该圆形的位置,仔细阅读代码和相关注释,将程序补充完整。
【代码6】
import java.awt.*;
import java.awt.event.*;
public class CIUSAMPLE extends Frame implements MouseMotionListener, MouseListener
{
static CIUSAMPLE frm=new CIUSAMPLE ();
int x=70,y=60,posX=70,posY=60,dx,dy;
public static void main ( String args[])
{
frm.setTitle ("Dragging a circle");
frm.setSize ( 200,150 );
{{U}} (1) {{/U}}
frm.addMouseMotionListener ( frm );
frm. setVisible ( true );
}
public void mousePressed ( MouseEvent e )
{
{{U}} (2) {{/U}}
dy=e.getY () -posY;
}
public void mouseDragged ( MouseEvent e )
{
{{U}} (3) {{/U}}
y=e.getY () -dy;
if ( dx>0
{{U}} (4) {{/U}}
}
}
public void paint ( Graphics g )
{
g.setColor ( Color. pink ); // 设置绘图颜色为粉红
g.fillOval ( x,y,50,50 ); //以基准点为图形的左上角绘出圆形
{{U}} (5) {{/U}}
posY=y;
}
public void mouseMoved ( MouseEvent e ) { }
public void mouseReleased ( MouseEvent e ) { }
public void mouseEntered ( MouseEvent e ) { }
public void mouseExited ( MouseEvent e ) { }
public void mouseClicked ( MouseEvent e ) { }
}
填空题阅读以下函数说明和C语言函数,将应填入{{U}} (n) {{/U}}处的字句写在对应栏内。 [说明] 某银行共发出M张储蓄卡,每张储蓄卡拥有唯一的卡号,每天每张储蓄卡至多支持储蓄卡持有者的N笔“存款”或“取款”业务。程序中用数组card[M][N+3]中的每一行存放一张储蓄卡的有关信息,其中: card[i][0]存放第i张卡的卡号; card[i][1]存放第i张卡的余额; card[i][2]存放第i张卡的当日业务实际发生笔数; card[i][3]~card[i][N+2]存放第i张卡的当日存取款金额,正值代表存款,负值代表取款。 当持卡者输入正确的卡号、存款或取款金额后,程序进行相应的处理;若输入不正确的数据,程序会提示持卡者重新输入;若输入的卡号为负数时,银行终止该卡的当日业务。 [C程序] #include<stdio.H> #define M 6 #define N 5 long card[M][N+3]={{9801,2000,0,},{9812,2000,2,},{9753,3000,1,}, {8750,500,0,},{9604,2800,3,),(8901,5000,5,}}; int locate(long card[][N+3],int m,long no) { int i; for(i=0;i<m;i++) if( {{U}}(1) {{/U}}==no) return i; {{U}} (2) {{/U}}; } main() {long cardNo,money; int k; while(1){ printf("请输入卡号:/n"); scanf("%1d", if(cardNo<0) break; k=locate(card,M,cardNo); if(k==-1){ printf("不存在%id号的储蓄卡/n",cardNo); continue; } printf("请输入金额(正值代表存款,负值代表取款):/n"); scanf("%id", if(card[k][1]+money<0){ printf("存款余额不足,不能完成本次的取款业务/n"); continue; } if(card[k][2]==N){ printf("已完成本卡的当日业务/n"); continue; } /*处理一笔业务的数据*/ card[k]{{U}} (3) {{/U}}=money; {{U}} (4) {{/U}}; {{U}} (5) {{/U}}; } }
填空题阅读以下说明和C++程序,将应填入{{U}} (n) {{/U}}处的字句写在对应栏内。 [说明] 下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。 [C++程序] #include <iostream.h> class crop_assessment { int actual_crop; int ideal_crop; public: void set(int in_actual,int in_ideal) { actual crop=in_actual; ideal_crop=in_ideal; } int get_actual_crop(void){{{U}} (1) {{/U}};} int get_ideal_crop(void){{{U}} (2) {{/U}};) }; Class lot_size { int length; int width; {{U}} (3) {{/U}} crop; public: void set(int 1,int w,int a,int i) { length=1; width=w; crop.set(a,i); } int get_area(void){return length*width;} int get_data(void){return{{U}} (4) {{/U}};} int get_data2(void)freturn{{U}} (5) {{/U}};} } int main() { Los_size small,medium; small.set(5,5,5,25); medium.set(10,10,10,50); cout<<"For a small lot of area"<<smallget_area()<<“/n”; cout<<"the actual crops are$"<<small.get_data2()<<"/n"; cout<<"and ideal crops are$”<<small.get_data()<<"/n"; cout<<"For a medium Lot of area"<<medium.get area()<<:/n”; cout<<"the actual crops are$"<<medium.get_data2()<<"/n"; cout<<"and ideal crops are$"<<medium.get_data()<<"/n"; return 0; }
填空题[说明]
编写一个Applet程序,接受HTML文件传递的整数参数,根据该参数指定Applet中文本框的长度。编写对应的HTML文件运行这个Applet。
[Java 代码]
import java. applet.*;
import java. awt.*;
public class chuangdics extends {{U}}(1) {{/U}}
{
TextField tf=new TextField ();
int tfLength=0;
public void init()
{
try
{
tfLength=Integer. parseInt({{U}} (2) {{/U}}("length"));
tf. setColumns (tfLength);
add (tf);
}
catch (NumberFormatException nfe)
{
tf.{{U}} (3) {{/U}}("HTML 文件传人的参数格式错误。");
add(tf);
}
}
}
[HTML 代码]
<html>
<head>
<title>{{U}} (4) {{/U}}</title>
</head>
<body>
<hr>
<applet code=chuangdics width=700 height=150>
<param name=length value=20>
{{U}}(5) {{/U}}
<hr>
</body>
</htmI>
填空题[说明]
编写一个函数,输入为偶数时,调用函数求1/2+?/+…+1/n,当输入n为奇数时,调用函数1/1+1/3+…+1/n (利用指针函数)。
[函数]
#include "stdio. h",
main()
{
float peven (),podd (),dcall ();
float sum;
int n;
while{{U}} (1) {{/U}}
{
scanf("%d",&n);
if (n>1)
break;
}
if(n%2==0)
{
printf("Even="):
(1);
}
else
{
pfinff("Odd=");
{{U}} (2) {{/U}};
}
printf("%f",sum);
}
float peven (int n)
{
float s;
int i
s=1;
for(i=2;i<=n;i+=2)
{{U}} (3) {{/U}};
return (s);
}
float podd (n)
int n;
{
float s;
int i;
s=0;
for(i=1 i<=n;i+=2)
{{U}} (4) {{/U}};
return (s);
}
float dcall(fp,n)
float (*fp) ();
int n;
{
float s;
{{U}}(5) {{/U}};
returu (s);
}
填空题[说明] 下面的程序是通过双链结构来查找学生的信息程序的一部分,即创建双向链表部分。 [函数] #include <stdio.h> #define N 10 typedef struct node char name [20]; struct node *llink,*rlink; stud; /*双链表的结构定义*/ /*双链表的创建*/ stud * creat (int n) stud *p,*h,*s; int i; if ((h= (stud *) malloc (sizeof (stud))) ==NULL) printf ("cannot find space! /n") ; exit (0) ; h->name[0]='/0'; h->llink=NULL; h->rlink=NULL; p=h; for(i=0; i<n; i++) if((s= (stud *) malloc (sizeof (stud)))==NULL) printf ("cannot find space! /n") ; exit (0) ; (1) ; printf("Please input the %d man's name: ";i+1) ; scanf("%s", s->name) ; (2) ; (3) ; p=s ; (4) ; (5) ; return (h) ;
填空题【说明】
以下代码实现了当用户退出界面时,判断TextEdit中的文字是否发生改变,弹出对话框判断,让用户选择是否保存文件或取消退出界面操作。阅读下面的代码,将其补充完整。
【代码7-1】
Begin VB.Form Forml
//...窗体描述(略)
Begin VB.TextBox TextEdit
Height = 1830
Left = 180
Tablndex = 0
Text = "TextEdit"
Top = 360
Width = 3885
End
//...窗体描述(略)
End
【代码7-2】
Dim txtchange As Boolean
Dim myval As String
Private Sub Form Load ()
TextEdit.Text: "CIU, 中国软考联盟!"
txtchange = False
End Sub
【代码7-3】
Private Sub TextEdit_Change ()
Static notchange As Boolean
{{U}} (1) {{/U}}
notchange = Tree
End Sub
Private Sub Form_Unload ( Cancel As Integer )
Dim myval As String
If{{U}} (2) {{/U}}Then
myval = MsgBox ( "保存文件的更改吗?", vbYesNoCancel, "提示信息" )
If{{U}} (3) {{/U}}Then
MsgBox "保存成功"
End
End If
If{{U}} (4) {{/U}}Then End
If{{U}} (5) {{/U}}Then Cancel = 1
End If
End Sub
填空题[说明]
本程序求3~100之间的所有素数(质数)并统计个数;同时将这些素数从小到大依次写入顺序文件 E:/dataout.txt;素数的个数显示在窗体Form1上。
[Visual Basic 代码]
Private Sub Command1 Click ( )
Dim count as integer, flag as Boolean
Dim t1 as Integer, t2 as Integer
{{U}} (1) {{/U}}
Count=0
For t1=3 to 100
{{U}} (2) {{/U}}
For t2=2 to Int (Sqr (t1))
If{{U}} (3) {{/U}}Then flag=False
Next t2
{{U}} (4) {{/U}}
count=count +1
write #1, t1
End if
Next t1
{{U}} (5) {{/U}}
Close #1
End Sub
填空题阅读以下说明和算法,完善算法并回答问题,将解答写在对应栏内。[说明]假设以二维数组G[1..m,1..n]表示一幅图像各像素的颜色,则G[i,j]表示区域中点(i,j]处的颜色,颜色值为0到k的整数。下面的算法将指定点(i0,j0)所在的同色邻接区域的颜色置换为给定的颜色值。约定所有与点(i0,j0)同色的上、下、左、右可连通的点组成同色邻接区域。例如,一幅8×9像素的图像如图1-1所示。设用户指定点(3,5),其颜色值为0,此时其上方(2,5)、下方(4,5)、右方(3,6)邻接点的颜色值都为0,因此这些点属于点(3,5)所在的同色邻接区域,再从上、下、左、右四个方向进行扩展,可得出该同色邻接区域的其他点(见图1-1中的阴影部分)。将上述同色区域的颜色替换为颜色值7所得的新图像如图1-2所示。[算法]输入:矩阵G,点的坐标(i0,j0),新颜色值newcolor。输出:点(i0,j0)所在同色邻接区域的颜色置换为newcolor之后的矩阵G。算法步骤(为规范算法,规定该算法只在第七步后结束):第一步:若点(i0,j0)的颜色值与新颜色值newcolor相同,则(1);第二步:点(i0,j0)的颜色值→oldcolor;创建栈S,并将点坐标(i0,j0)入栈;第三步:若(2),则转第七步;第四步:栈顶元素出栈→(x,y),并(3);第五步:1)若点(x,y-1)在图像中且G[x,y-1]等于oldcolor,则(x,y-1)入栈S;2)若点(x,y+1)在图像中且G[x,y+1]等于oldcolor,则(x,y+1)入栈S;3)若点(x-1,y)在图像中且G[x-1,y]等于oldcolor,则(x-1,y)入栈S;4)若点(x+1,y)在图像中且G[x+1,y)等于oldcolor,则(x+1,y)入栈S:第六步:转(4);第七步:算法结束。[问题]是否可以将算法中的栈换成队列?回答:(5)。
