第10章 pointer
- 格式:ppt
- 大小:382.00 KB
- 文档页数:45
第10章宏对象宏是一种工具,允许用户自动执行任务,以及向窗体、报表和控件中添加功能。
在Access中执行特定任务的操作或者操作集合就需要用到宏,每个操作宏实现特定的功能,这些宏操作是Access自带的。
本章将要介绍如何在Access中创建、设计和使用宏,以便用户在使用Access时可以独立运用宏的操作。
本章重点:宏概述宏的创建与设计宏的运行与调试宏的具体应用宏的安全设置10.1宏概述宏可以是包含操作序列的一个宏,也可以是由多个宏组成的宏组。
在某些条件下运行宏时使用表达式可以决定某个操作是否执行。
例如,打开和关闭窗体、显示和隐藏工具栏、预览或者打印报表等,通过执行宏,Access 能够有次序地自动执行一连串的操作。
在Access中,通过直接执行宏或者使用包含宏的用户界面,可以完成许多繁杂的需要人工的操作,但是在其他一些数据库中,要想完成同样的操作,就要采用编程的方法才能实现。
编写宏的时候,用户不需要记住各种语法,在宏的设计环境中,每个宏的操作参数都会显示出来。
保存宏及宏组都需要命名,命名的方法与其他数据库对象相同。
用户可以将Access宏看作是一种简化的编程语言,利用这种语言生成要执行的操作(操作是宏的基本组成部分,这是一种自含式指令,可以与其他操作相结合来自动执行任务。
在其他宏语言中有时称为命令。
)列表来创建代码。
生成宏时,用户从下拉列表中选择每个操作,然后为每个操作填写必需的信息。
宏使用户能够向窗体、报表和控件中添加功能,而无须在VBA模块中编写代码。
宏提供了VBA中可用命令的子集,大多数人都认为生成宏比编写VBA代码更容易。
10.1.1宏的功能在Access中,可以将宏看作一种简化了的编程语言。
通过使用宏,用户无须在VBA模块中编写代码就可以向窗体、报表和控件中添加所需的功能。
总的来说,宏可以帮助用户完成以下工作。
·打开/关闭数据表、窗体,打印报表和执行查询。
·筛选、查找数据记录。
c语言程序设计教程第三版习题答案C语言程序设计教程第三版习题答案第一章:C语言概述1. 简述C语言的特点。
C语言是一种结构化编程语言,具有高级语言的特点,同时支持底层硬件操作。
其特点包括:简洁、高效、可移植、丰富的运算符、数据结构支持、广泛的库函数等。
2. 什么是编译型语言?编译型语言是指源代码在执行前需要通过编译器转换成机器语言的程序设计语言。
C语言就是一种编译型语言。
第二章:数据类型、运算符和表达式1. 列出C语言的基本数据类型。
C语言的基本数据类型包括:整型(int)、字符型(char)、浮点型(float和double)。
2. 说明赋值运算符的用法。
赋值运算符(=)用于将右侧表达式的值赋给左侧的变量。
例如:`int a = 10;` 将整数值10赋给变量a。
第三章:控制结构1. 什么是条件语句?条件语句用于根据条件的真假来执行不同的代码块。
C语言中的条件语句主要有if语句和switch语句。
2. 循环语句有哪些?C语言中的循环语句主要有for循环、while循环和do-while循环。
第四章:数组和字符串1. 数组的声明和初始化方式。
数组声明的一般形式为:`type arrayName[arraySize];`。
初始化可以使用花括号一次性赋值,如:`int arr[5] = {1, 2, 3, 4, 5};`。
2. 字符串在C语言中的表示方法。
在C语言中,字符串以字符数组的形式存在,以空字符('\0')作为结束标志。
第五章:函数1. 函数的定义和调用。
函数定义的一般形式为:`returnTypefunctionName(parameterList) { /* function body */ }`。
调用函数时,使用其名称和必要的参数。
2. 函数的参数传递方式有哪些?C语言中函数的参数传递方式主要有值传递(pass by value)和引用传递(pass by reference)。
INTEL 80383 程序员参考手册第十章初始化当RESET引脚有信号后,80386的某些寄存器被设置为预定义值。
这些预定义值对于执行引导程序来说已经足够了,但是为了利用处理器的所有特性,软件必须做一些额外的初始化工作。
10.1 复位后的处理器状态EAX的内容取决于上电自检的结果。
自检由复位结束后外部声明BUSY#来决定。
如果自检通过,EAX为零。
非零值表示80386的某些单元出错。
如果不要求自检,则EAX的值未定义。
复位后,DX包含部件标识符和版本号,如图10-1所示。
DH为3,表示80386。
DL包含一个唯一的代表版本等级的标识符。
控制寄存器0(CR0)中的值如图10-2所示。
如果配置了(取决于上电复位后ERROR#引脚的状态)80387,CR0的ET位被置位。
如果ET被复位,则说明配置了80287或者没有协处理器。
对于后面的两种情况,需要在软件中做测试加以区分。
其他寄存器和标志位设置如下:EFLAGS =00000002HIP =0000FFF0HCS selector =000HDS selector =0000HES selector =0000HSS selector =0000HFS selector =0000HGS selector =0000HIDTR:base =0所有没有提到的寄存器为未定义。
这些设置暗示处理器开始了实地址模式,中断被关闭。
10.2 实地址模式的软件初始化在实地址模式下,为了获得该模式下的所有特性,一些结构必须被初始化。
10.2.1 堆栈在堆栈段寄存器装载之前,任何使用堆栈的指令都不能执行。
SS必须指向内存中的某个区域。
10.2.2 中断表中断在80386的初始化状态为不可用状态;然而,当异常或不可屏蔽中断(NMI)发生时,处理器仍然会试图访问中断表。
初始化软件应该执行一下某个动作:●把IDTR中的上限值改为零。
这将导致在有异常或不可屏蔽中断发生的时候导致宕机。
第1章进制及码元1.进制转换129= 81H= 10000001B=201Q298= 12AH= 100101010B=452Q1000= 3E8H= 1111101000B= 1750Q5DH= 1011101 B= 135 Q= 93 D3E8H= 1111101000 B= 1750Q= 1000 D;357Q=11101111 B= 0EF H= 239 D3.数据表示范围:一字节的无符号数表示范围为0~255,有符号数(补码)表示范围为-l28—+127。
一个字的无符号数表示范围为0~65535,有符号数(补码)表示范围为—32768~+32767。
N位二进制数的无符号数表示范围为0~(2N-1),有符号数(补码)表示范围为-2N-1~(2N-1-1).4.35H代表的ASCII字符为'5',代表十六进制数时等价的十进制值为53 ,代表压缩8421BCD码等价的十进制值为35 ,代表非压缩8421BCD码等价的十进制值为5。
5.FFH代表无符号数时等价的十进制值为255 ,代表补码有符号数时等价的十进制值为一1 ,代表反码有符号数时等价的十进制值为一0 ,代表原码有符号数时等价的十进制值为一l27。
6.--20的8位二进制补码为ECH ,原码为94H ,反码为EBH 。
158的16位二进制补码为009EH,原码为009EH ,反码为009EH 。
第2章微机硬件基础1.计算机系统硬件的五大功能部件及其主要功能?答:硬件系统按功能模块分为运算器、控制器、存储器、输入设备、输出设备。
运算器主要完成算术运算、逻辑运算及移位运算,其中主要包括算术逻辑运算单元Arithmetic Logic Unit,ALU)和暂存数据(原始、中间、结果)的寄存器(Register,R)。
控制器实现对计算机部件的协调调度完成指令的分析执行,其中主要有程序计数器Program Counter,PC)或叫指令指针(Instruction Pointer,IP)、指令寄存器(Instruction register,IR)、指令译码器(Instruction Decoder,ID)、微操作命令发生器、时序发生器等。
Chapter10Michelle Bodnar,Andrew LohrApril12,2016Exercise10.1-14414134141841Exercise10.1-2We will call the stacks T and R.Initially,set T.top=0and R.top=n+1. Essentially,stack T uses thefirst part of the array and stack R uses the last part of the array.In stack T,the top is the rightmost element of T.In stack R, the top is the leftmost element of R.Algorithm1PUSH(S,x)1:if S==T then2:if T.top+1==R.top then3:error“overflow”4:else5:T.top=T.top+16:T[T.top]=x7:end if8:end if9:if S==R then10:if R.top−1==T.top then11:error“overflow”12:else13:R.top=R.top−114:T[T.top]=x15:end if16:end if1Algorithm2POP(S)if S==T thenif T.top==0thenerror“underflow”elseT.top=T.top−1.return T[T.top+1]end ifend ifif S==R thenif R.top==n+1thenerror“underflow”elseR.top=R.top+1.return R[R.top−1]end ifend ifExercise10.1-34414131313838Exercise10.1-4Algorithm3ENQUEUEif Q.head==Q.tail+1,or Q.head==1and Q.tail==Q.length then error“overflow”end ifQ[Q.tail]=xif Q.tail==Q.length thenQ.tail=1elseQ.tail=Q.head+1end ifExercise10.1-5As in the example code given in the section,we will neglect to check for overflow and underflow errors.2Algorithm4DEQUEUEerror“underflow”end ifx=Q[Q.head]if Q.head==Q.length thenQ.head=1elseQ.head=Q.head+1end ifreturn xAlgorithm5HEAD-ENQUEUE(Q,x) Q[Q.head]=xif Q.head==1thenQ.head=Q.lengthelseQ.head=Q.head−1end ifAlgorithm6TAIL-ENQUEUE(Q,x) Q[Q.tail]=xif Q.tail==Q.length thenQ.tail=1elseQ.tail=Q.tail+1end ifAlgorithm7HEAD-DEQUEUE(Q,x) x=Q[Q.head]if Q.head==Q.length thenQ.head=1elseQ.head=Q.head+1end ifAlgorithm8TAIL-DEQUEUE(Q,x) x=Q[Q.tail]if Q.tail==1thenQ.tail=Q.lengthelseQ.tail=Q.tail−1end if3Exercise10.1-6The operation enqueue will be the same as pushing an element on to stack 1.This operation is O(1).To dequeue,we pop an element from stack2.If stack 2is empty,for each element in stack1we pop it off,then push it on to stack2. Finally,pop the top item from stack2.This operation is O(n)in the worst case.Exercise10.1-7The following is a way of implementing a stack using two queues,where pop takes linear time,and push takes constant time.Thefirst of these ways,consists of just enqueueing each element as you push it.Then,to do a pop,you dequque each element from one of the queues and place it in the other,but stopping just before the last element.Then,return the single element left in the original queue.Exercise10.2-1To insert an element in constant time,just add it to the head by making it point to the old head and have it be the head.To delete an element,it needs linear time because there is no way to get a pointer to the previous element in the list without starting at the head and scanning along.Exercise10.2-2The PUSH(L,x)operation is exactly the same as LIST-INSERT(L,x).The POP operation sets x equal to L.head,calls LIST-DELETE(L,L.head),then returns x.Exercise10.2-3In addition to the head,also keep a pointer to the last element in the linked list.To enqueue,insert the element after the last element of the list,and set it to be the new last element.To dequeue,delete thefirst element of the list and return it.Exercise10.2-4First let L.nil.key=k.Then run LIST-SEARCH’as usual,but remove the check that x=L.nil.Exercise10.2-5To insert,just do list insert before the current head,in constant time.To search,start at the head,check if the element is the current node being in-spected,check the next element,and so on until at the end of the list or you4found the element.This can take linear time in the worst case.To delete,again linear time is used because there is no way to get to the element immediately before the current element without starting at the head and going along the list.Exercise10.2-6Let L1be a doubly linked list containing the elements of S1and L2be a doubly linked list containing the elements of S2.We implement UNION as fol-lows:Set L1.nil.prev.next=L2.nil.next and L2.nil.next.prev=L1.nil.prev so that the last element of L1is followed by thefirst element of L2.Then set L1.nil.prev=L2.nil.prev and L2.nil.prev.next=L1.nil,so that L1.nil is the sentinel for the doubly linked list containing all the elements of L1and L2. Exercise10.2-7Algorithm9REVERSE(L)a=L.head.nextb=L.headwhile a=NIL dotmp=a.nexta.next=bb=aa=tmpend whileL.head=bExercise10.2-8We will store the pointer value for L.head separately,for convenience.In general,A XOR(A XOR C)=C,so once we know one pointer’s true value we can recover all the others(namely L.head)by applying this rule.Assuming there are at least two elements in the list,thefirst element will contain exactly the address of the second.Algorithm10LISTnp-SEARCH(L,k)p=NILx=L.headwhile x=NIL and x.key=k dotemp=xx=pXORx.npp=tempend whileTo reverse the list,we simply need to make the head be the“last”ele-5Algorithm11LISTnp-INSERT(L,x)x.np=L.headL.nil.np=xXOR(L.nil.npXORL.head)L.head=xAlgorithm12LISTnp-Delete(L,x)L.nil.np=L.nil.npXORL.headXORL.head.npL.head.np.np=L.head.np.npXORL.headment before L.nil instead of thefirst one after this.This is done by settingL.head=L.nil.npXORL.head.Exercise10.3-1A multiple array version could be L=2,/34567/124819511/23456A single array version could be L=4,127/410481371916105191311/16 Exercise10.3-2Algorithm13Allocate-Object()if free==NIL thenerror“out of space”elsex=freefree=A[x+1]end ifExercise10.3-3Allocate object just returns the index of some cells that it’s guaranteed tonot give out again until they’ve been freed.The prev attribute is not modified because only the next attribute is used by the memory manager,it’s up to the code that calls allocate to use the prev and key attributes as it seesfit.Exercise10.3-4For ALLOCATE-OBJECT,we will keep track of the next available spot inthe array,and it will always be one greater than the number of elements being stored.For FREE-OBJECT(x),when a space is freed,we will decrement the6Algorithm14Free-Object(x)A[x+1]=freefree=xposition of each element in a position greater than that of x by1and update pointers accordingly.This takes linear time.Exercise10.3-5See the algorithm COMP ACT IF Y−LIST(L,F)Exercise10.4-1181274510221Note that indices8and2in the array do not appear,and,in fact do not represent a valid tree.Exercise10.4-2See the algorithm PRINT-TREE.Exercise10.4-3Exercise10.4-4See the algorithm PRINT-TREE.Exercise10.4-5See the algorithm INORDER-PRINT’(T)Exercise10.4-6Our two pointers will be left and right.For a node x,x.left will point to the leftmost child of x and x.right will point to the sibling of x immediately to its right,if it has one,and the parent of x otherwise.Our boolean value b,stored at x,will be such that b=depth(x)mod2.To reach the parent of a node, simply keep following the“right”pointers until the parity of the boolean value changes.Tofind all the children of a node,start byfinding x.left,then follow7Algorithm15COMPACTIFY-LIST(L,F)if n=m thenreturnend ife=max{max i∈[m]{|key[i]|},max i∈L{|key[i]|}}increase every element of key[1..m]by2efor every element of L,if its key is greater than e,reduce it by2e f=1while key[f]<e dof++end whilea=L.headif a>m thennext[prev[f]]=next[f]prev[next[f]]=prev[f]next[f]=next[a]key[f]=key[a]prev[f]=prev[a]F REE−OBJECT(a)f++while key[f]<e dof++end whileend ifwhile a=L.head doif a>m thennext[prev[f]]=next[f]prev[next[f]]=prev[f]next[f]=next[a]key[f]=key[a]prev[f]=prev[a]F REE−OBJECT(a)f++while key[f]<e dof++end whileend ifend while8Algorithm16PRINT-TREE(T.root) if T.root==NIL thenreturnelsePrint T.root.keyPRINT-TREE(T.root.left)PRINT-TREE(T.root.right)end ifAlgorithm17INORDER-PRINT(T) let S be an empty stackpush(S,T)while S is not empty doU=pop(S)if U=NIL thenprint U.keypush(S,U.left)push(S,U.right)end ifend whileAlgorithm18PRINT-TREE(T.root) if T.root==NIL thenreturnelsePrint T.root.keyx=T.root.left−childwhile x=NIL doPRINT-TREE(x)x=x.right−siblingend whileend if9Algorithm19INORDER-PRINT’(T) a=T.leftprev=Twhile a=T doif prev=a.left thenprint a.keyprev=aa=a.rightelse if prev=a.right thenprev=aa=a.pelse if prev=a.p thenprev=aa=a.leftend ifend whileprint T.keya=T.rightwhile a=T doif prev=a.left thenprint a.keyprev=aa=a.rightelse if prev=a.right thenprev=aa=a.pelse if prev=a.p thenprev=aa=a.leftend ifend while10the“right”pointers until the parity of the boolean value changes,ignoring thislast node since it will be x.Problem10-1For each,we assume sorted means sorted in ascending orderunsorted,single sorted,single unsorted,double sorted,double SEARCH(L,k)n n n nINSERT(L,x)1111DELET E(L,x)n n11SUCCESSOR(L,x)n1n1P REDECESSOR(L,x)n n n1 MINIMUM(L,x)n1n1MAXIMUM(L,x)n n n1 Problem10-2In all three cases,MAKE-HEAP simply creates a new list L,sets L.head=NIL,and returns L in constant time.Assume lists are doubly linked.To realizea linked list as a heap,we imagine the usual array implementation of a binaryheap,where the children of the i th element are2i and2i+1.a.To insert,we perform a linear scan to see where to insert an element suchthat the list remains sorted.This takes linear time.Thefirst element in thelist is the minimum element,and we canfind it in constant time.Extract-minreturns thefirst element of the list,then deletes it.Union performs a mergeoperation between the two sorted lists,interleaving their entries such thatthe resulting list is sorted.This takes time linear in the sum of the lengthsof the two lists.b.To insert an element x into the heap,begin linearly scanning the list untilthefirst instance of an element y which is strictly larger than x.If no suchlarger element exists,simply insert x at the end of the list.If y does exist,replace y t by x.This maintains the min-heap property because x≤y andy was smaller than each of its children,so x must be as well.Moreover,xis larger than its parent because y was thefirst element in the list to exceedx.Now insert y,starting the scan at the node following x.Since we checkeach node at most once,the time is linear in the size of the list.To get theminimum element,return the key of the head of the list in constant time.To extract the minimum element,wefirst call MINIMUM.Next,we’ll replacethe key of the head of the list by the key of the second smallest element yin the list.We’ll take the key stored at the end of the list and use it toreplace the key of y.Finally,we’ll delete the last element of the list,and callMIN-HEAPIFY on the list.To implement this with linked lists,we need tostep through the list to get from element i to element2i.We omit this detailfrom the code,but we’ll consider it for runtime analysis.Since the value ofi on which MIN-HEAPIFY is called is always increasing and we never need11to step through elements multiple times,the runtime is linear in the length of the list.Algorithm20EXTRACT-MIN(L)min=MINIMUM(L)Linearly scan for the second smallest element,located in position i.L.head.key=L[i]L[i].key=L[L.length].keyDELETE(L,L[L.length])MIN-HEAPIFY(L[i],i)return minAlgorithm21MIN-HEAPIFY(L[i],i)1:l=L[2i].key2:r=L[2i+1].key3:p=L[i].key4:smallest=i5:if L[2i]=NIL and l<p then6:smallest=2i7:end if8:if L[2i+1]=NIL and r<L[smallest]then9:smallest=2i+110:end if11:if smallest=i then12:exchange L[i]with L[smallest]13:MIN-HEAPIFY(L[smallest],smallest)14:end ifUnion is implemented below,where we assume A and B are the two list representations of heaps to be merged.The runtime is again linear in the lengths of the lists to be merged.c.Since the algorithms in part b didn’t depend on the elements being distinct,we can use the same ones.Problem10-3a.If the original version of the algorithm takes only t iterations,then,we havethat it was only at most t random skips though the list to get to the desired value,since each iteration of the original while loop is a possible random jump followed by a normal step through the linked list.b.The for loop on lines2-7will get run exactly t times,each of which is constantruntime.After that,the while loop on lines8-9will be run exactly X t times.So,the total runtime is O(t+E[X t]).12Algorithm22UNION(A,B)1:if A.head=NIL then2:return B3:end if4:i=15:x=A.head6:while B.head=NIL do7:if B.head.key≤x.key then8:Insert a node at the end of list B with key x.key 9:x.key=B.head.key10:Delete(B,B.head)11:end if x=x.next12:end while13:return Aing equation C.25,we have that E[X t]= ∞i=1P r(X t≥i).So,we needto show that P r(X t≥i)≤(1−i/n)t.This can be seen because having X t being greater than i means that each random choice will result in an element that is either at least i steps before the desired element,or is after the desired element.There are n−i such elements,out of the total n elements that we were pricking from.So,for a single one of the choices to be from such a range, we have a probability of(n−i)/n=(1−i/n).Since each of the selections was independent,the total probability that all of them were is(1−i/n)t, as stly,we can note that since the linked list has length n,the probability that X t is greater than n is equal to zero.d.Since we have that t>0,we know that the function f(x)=x t is increasing,so,that means that x t≤f(x).So,n−1r=0r t=nr t dr≤nf(r)dr=n t+1e.E[X t]≤nr=1(1−r/n)t=nr=1ti=0ti(−r/n)i=ti=0nr=1ti(−r/n)i=ti=0ti(−1)in i−1+n−1r=0(r)t/n≤ti=0ti(−1)in i−1+n i+1/n ≤ti=0ti(−1)in ii+1=1t+1ti=0t+1i+1(−n)i≤(1−n)t+1t+1f.We just put together parts b and e to get that it runs in time O(t+n/(t+1)).But,this is the same as O(t+n/t).13g.Since we have that for any number of iterations t that the first algorithm takes to find its answer,the second algorithm will return it in time O (t +n/t ).In particular,if we just have that t =√n .The second algorithm takestime only O (√n ).This means that tihe first list search algorithm is O (√n )as well.h.If we don’t have distinct key values,then,we may randomly select an element that is further along than we had been before,but not jump to it because it has the same key as what we were currently at.The analysis will break when we try to bound the probability that X t ≥i .14。
计算机专业英语课后答案第1章信息技术、互联⽹和你选择1. The keyboard, mouse display, and system unit are: 键盘、⿏标、显示器和系统单元是: hardware2. Programs that coordinate computer resources, provide an interface, and run applications are knownas: 协调计算机资源、提供接⼝和运⾏应⽤程序的程序被称为: operating systems3. A browser is an example of a: 浏览器就是通⽤应⽤程序的⼀个例⼦ general-purpose application4. Although not as powerful as a supercomputer, this type of computer is capable of great processingspeeds and data storage. 虽然没有超级计算机那么强⼤,但这种类型的计算机具有很⾼的处理速度和数据存储能⼒。
mainframe ⼤型计算机5. Apple' s Watch is what type of computer? 苹果⼿表是什么类型的电脑? wearable可穿戴6. RAM is a type of: RAM是存储器的⼀种 memory7. Unlike memory, this type of storage holds data and programs even after electrical power to thecomputer system has been turned off. 与内存不同的是,这种类型的存储即使在计算机系统断电后也能保存数据和程序 secondary8. The type of file created by word processors to save, for example, memos, term papers, and letters. 由⽂字处理程序创建的⽂件类型,如备忘录、学期论⽂和信件 document9. Uses the internet and the web to shift many computer activities from a user' scomputer to computerson the internet。
简单句只有一个主语(或并列主语)和一个谓语(或并列谓语)的句子叫做简单句。
The old man lives in this village .(一个主语+一个谓语)Li Qing and Li Hui went there together.( 并列主语+一个谓语)She went out ,bought a bottle of wine and returned hurriedly.(一个主语+三个并列谓语)They are twins.(一个主语+连系动词+表语)She always keeps the room clean and tidy.(一个主语+一个谓语)英语简单句五种基本句型(一):基本句型一: 主+系+表此句型的句子有一个共同的特点:句子谓语动词都不能表达一个完整的意思,必须加上一个表明主语身份或状态的表语构成复合谓语,才能表达完整的意思.这类动词叫做连系动词.系动词分两类:be, look, keep, seem, feel, remain, prove, smell, sound,hold, stay, stand(保持)等属一类,表示情况;get, grow, become, turn, come ,go ,等属另一类,表示变化.其中be 本身没有什么意义,只起连系主语和表语的作用.其它系动词仍保持其部分词义.1. This is an English-Chinese dictionary.2. The dinner smells good.3. His face turned red.4. Everything looks different.5. He is growing tall and strong.连系动词不用于被动语态(若用作行为动词除外)。
【正】The apple tastes sweet .这苹果尝起来很甜。
【误】The apple is tasted sweet.●作表语的一般不能是-ly结尾的副词,否则句子不能成立。