云南大学软件学院 大二年级上册学期专业英语重点及习题总结.pdf
《云南大学软件学院 大二年级上册学期专业英语重点及习题总结.pdf》由会员分享,可在线阅读,更多相关《云南大学软件学院 大二年级上册学期专业英语重点及习题总结.pdf(101页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、2.1 Perform the following number conversions:(十六进制与二进制的转换)A.0 x39A7F8 to binaryHexadecimal 3 9 A 7 F 8Binary 0011 1001 1010 0111 1111 1000B.Binary 1100100101111011 to hexadecimalBinary1100100101111011HexadecimalC97BC.0 xD5E4C to binaryHexadecimalD5E4cBinary11010101111001001100D.Binary 10011011100111
2、10110101 to hexadecimalBinary 10 0110 1110 0111 1011 0101Hexadecimal 2 6 E 7 B 52.2 Fill in the blank entries in the following table,giving the decimal and hexadecimalrepresentations of different powers of 2:n 2An(Decimal 十进制)2八 n(Hexadecimal 十六进制)95120 x20019524,2880 x800001416,3840 x40001665,5360
3、x1000017131,0720 x200005320 x2071280 x802.3A single byte can be represented by two hexadecimal digits.Fill in the missing entries in thefollowing table,giving the decimal,binary,and hexadecimal values of different byte patterns:(做题认真即可进制之间的转换)DecimalBinaryHexadecimal00000 00000 x00167=10*16+71010011
4、10 xA762=3*16+140011 11100 x3E188=11*16+121011 1100OxBC3*16+7=550011 01110 x378*16+8=1361000 10000 x8815*16+3=2431111 00110 xF35*16+2=820101 00100 x5210*16+12=1721010 1100OxAC14*16+7=231111001110 xE72.4 Without converting the numbers to decimal or binary,try to solve the following arithmeticproblems
5、,giving the answers in hexadecimal.Hint:Just modify the methods you use forperforming decimal addition and subtraction to use base 16.(注意给出的数字是二:进制卜进制还是十六进制)十六进制得写OxA.0 x503c+0 x8=0 x5044.Adding 8 to hex c gives 4 with a carry of 1.(进位 1)B.0 x503c-0 x40=0 x4ffc.Subtracting 4 from 3 in the second dig
6、it position requires a borrowfrom the third(借位 1).Since this digit is 0,we must also borrow from the fourth position.C.0 x503c+64=0 x507c.Decimal 64(26)equals hexadecimal 0 x40.D.0 x50ea 0 x503c=0 xae.To subtract hex c(decimal 12)from hex a(decimal 10),we borrow16 from the second digit,giving hex e(
7、decimal 14).In the second digit,we now subtract 3 fromhex d(decimal 13),giving hex a(decimal 10).2.5 Consider the following three calls to show_bytes:(一个内存单元存放一个字节 8 个比特存储有两种方式:1 小端法一最低有效字节在最前面2 大端法最高有效字节在最前面)继续我TJ前面的示例,假设变鼠x类型为in t,位于地址0 x100处,有一个十六进制值为0 x01234567.地址范围0 x100-0 x103的字节顺序依籁于机器的类型:大端法
8、0 x100 0 x101_ 0 x102 0 x103-0 45|67|一小端法_0 x100 0 x101 0 x102 0 x103一 61|1 23|01|一注意 在字0 x01234567中 高位字节的十六迸制值为0 W I,而低位字节值为0 x67.个字节指针引用一个字节序列,其中每个字节都被认为是一个非负整数。第一个例程show_bytes的输入是一个字节序列的地址(它用一个字节指针来指示)和一个字节数。show_byles打印出以十六进制表小的字节。C格式化指令.2x”表示整数必须用至少两个数字的十六进制格式输出。int val=0 x87654321;byte_pointer
9、 valp=(byte_pointer)&val;show_bytes(valp,1);/*A.*/show_bytes(valp,2);/*B.*/show_bytes(valp,3);/*C.*/Indicate which of the following values will be printed by each call on a littleendianmachine and on a big-endian machine:(小端:从低到高 大端:从高到低)A.Little endian:21 Big endian:87B.Little endian:21 43 Big endi
10、an:87 65C.Little endian:21 43 65 Big endian:87 65 432.6 Using show_int and show_float,we determine that the integer 3510593 has hexadecimalrepresentation 0 x00359141,while the floating-point number 3510593.0 has hexadecimalrepresentation 0 x4A564504.A.Write the binary representations of these two he
11、xadecimal values.(用 进制表示这两个卜六进制)Using the notation of the example in the text,we write the two strings as follows:0 0 3 5 9 1 4 10000 0000 0011 0101 1001 0001 0100 00014 A 5 6 4 5 0 40100 10100101 011001000101 0000 0100B.Shift these two strings relative to one another to maximize the number of match
12、ing bits.Howmany bits match?(移动两个二进制串的相对位置,使其匹配位数最多,最多是多少位)With the second word shifted two positions to the right relative to the first,we find a sequencewith 21 matching bits.C.What parts of the strings do not match?We find all bits of the integer embedded in the floating-point number,except for t
13、he mostsignificant bit having value 1.Such is the case for the example in the text as well.In addition,thefloating-point number has some nonzero high-order bits that do not match those of the integer.c我们发现除了最高有效隹i,整数的所有我都嵌在浮点数中.这正好也是书中示例即IH,另 夕 卜,济点数有一些糕的船砧整数中的高位相嵋,2.7What would be printed as a resu
14、lt of the following call to show_bytes?(show.bytes返回指针 指向使用字节的最低字节地址)const char*s=abcdef;show_bytes(byte_pointer)s,strlen(s);Note that letters a through z have ASCII codes 0 x61 through 0 x7A.It prints 61 62 63 64 65 66.Recall also that the library routine strlen does not count theterminating null c
15、haracter,and so show_bytes printed only through the character f .2.8Fill in the following table showing the results of evaluating Boolean operations onbit vectors.Operation Result(运算比较简单 认真 已经给了编码 字节取反即可)a01101001b01010101 a(求 反)110010110J b10101010a&b(且)01000001alb(或)01111101a A b(异 或)fOOllllOO(同 为
16、0相 同 为0不 同 为1)2.9Computers generate color pictures on a video screen or liquid crystal display by mixing threedifferent colors of light:red,green,and blue.Imagine a simple scheme,with three different lights,each of which can be turned on or off,projecting onto a glass screen.计算机生成彩色照片视频屏幕或液晶显示器通过混合三
17、种不同颜色的光线:红、绿、蓝。想象一个简单的计划,三个不同的灯光,每一种都可以打开或关闭,投射在个玻璃屏幕。We can then create eight different colors based on the absence(0)or presence(1)of light sourcesR,G,and B:R G B Color0 0 0 Black0 0 1 Blue0 1 0 Green0 1 1 Cyan1 0 0 Red1 0 11 1 01 1 1MagentaYellowWhiteEach of these colors can be represented as a b
18、it vector of length 3,and we can apply Booleanoperations to them.A.The complement of a color is formed by turning off the lights that are on and turning on thelights that are off.What would be the complement of each of the eight colors listed above?Colors are complemented by complementing the values
19、 of R,G,and B.(取补)From this,we cansee that White is the complement of Black,Yellow is the complement of Blue,Magenta is thecomplement of Green,and Cyan is the complement of Red.B.Describe the effect of applying Boolean operations on the following colors:(:进 制 的 交 集 或 与 或 运 算)Blue I Green=Yellow&Cyan
20、=Red A Magenta=Blue(001)I Green(010)=Cyan(Oil)Yellow(110)&Cyan(011)=Green(010)Red(100)A Magenta(101)=Blue(001)2.lOAs an application of the property that a A a=0 for any bit vector a,consider the followingprogram:1 void inplace_swap(int*x,ini*y)2*y=*X A*y;/*Step 1 */3*x=*x 八 *y;/*Step 2*/4*y=x 八 *y;/
21、*Step 3*/5 As the name implies,we claim that the effect of this procedure is to swap the values stored at thelocations denoted by pointer variables x and y.Note that unlike the usual technique for swappingtwo values,we do not need a third location to temporarily store one value while we are movingth
22、e other.There is no performance advantage to this way of swapping;it is merely an intellectualAmusement.Starting with values a and b in the locations pointed to by x and y,respectively,fill in the table thatfollows,giving the values stored at the two locations after each step of the procedure.Use th
23、eproperties of A to show that the desired effect is achieved.Recall that every element is its ownadditive inverse(that is,a A a=0).(交换两个数)Step*x*yInitially a bStep 1 a aA bStep 2 a A(a A b)=(a A a)A b=b aA bStep 3 b bA(a A b)=(b A b)A a=a2.11 Armed with the function inplace_swap from Problem 2.10,yo
24、u decide to write code that willreverse the elements of an array by swapping elements from opposite ends of the array,workingtoward the middle.(一个串倒序)You aiTive at the following function:1 void reverse_array(int a,int ent)2 int first,last;3 for(first=0,last=cnt-1;4 first=last;5 first+,last)6 inplace
25、_swap(&afirst,&alast);7)When you apply your function to an array containing elements 1,2,3,and 4,you find the arraynow has,as expected,elements 4,3,2,and 1.When you try it on an array with elements 1,2,3,4,and 5,however,you are surprised to see that the array now has elements 5,4,0,2,and 1.In fact,y
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 云南大学软件学院 大二年级上册学期 专业英语重点及习题总结 云南大学 软件 学院 大二 年级 上册 学期 专业 英语 重点 习题 总结
限制150内