云南大学软件学院_大二年级上册学期__专业英语重点及习题总结.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 100110111001111
2、0110101 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、(Hexadecimal 十六进制)95120 x20019524,2880 x800001416,3840 x40001665,5360 x10
3、00017131,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+7101001110
4、xA762=3*16+140011 11100 x3E188=11*16+121011 1100OxBC3*16+7=550011 01110 x378*16+8=1361000 10000 x8815*16+3=243mi ooii0 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,givi
5、ng 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 digit pos
6、ition 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(decima
7、l 14).In the second digit,we now subtract 3 fromhex d(decimal 13),giving hex a(decimal 10).2.5Consider the following three calls to show_bytes:(个内存单元存放,个 工行 8 个比特存储有两种方式:1 小端法一-最低有效字节在最前面2 大端法最高有效字节在最前面)继续我们前面的示例,假设变鼠X类型为in i.位于地址0 x100处,有一个十六进制值为0 x01234567o地址范围0 x100 0 x103的字节顺序依赖于机器的类型:大端法0 x1000
8、 x1010 x1020 x10310 1231 4567|.小端法0 x1000 x1010 x1020 x10316 71451 2301 1 注意,在字0 x01234567中,高位字节的十六进制值为0 x 0 1,而低位字节值为0 x67。个字节指针引用一个字节序列,其中每个字节都被认为是一个非负整数。第一个例程show_bytes的输入是个字节序列的地址(它用一个字节指针来指示)和一个字节数。showj)ytes打印出以十六进制表小的字节。C格式化指令.2x”表示整数必须用至少两个数字的十六进制格式输出。int val=0 x87654321;byte_pointer valp=(b
9、yte_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 endian:87 65
10、C.Little endian:21 43 65 Big endian:87 65 432.6Using 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 hexadecimal
11、 values.(用二进制表不这两个卜六进制)Using the notation of the example in the text,we write the two strings as follows:0 0 3 5 9 1 4 100(X)0(X)0 0011 0101 1001 0001 0100 00014 A 5 6 4 5 0 40100 10100101 01100100 0101 0000 0100B.Shift these two strings relative to one another to maximize the number of matching bit
12、s.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 the most
13、significant 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.税们发现除了累有效佳1,搂数的所有他域在浮点数中.这正好也是书中示例的情况,另外,“就有一些解的雕蒲整数中的雕相匹配.2.7 What would be printed as a result of the f
14、ollowing 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 character,a
15、nd so show_bytes printed only through the character f .2.8 Fill in the following table showing the results of evaluating Boolean operations onbit vectors.Operationab a(求反)ba&b(且)a I b(或)aAb(异或)Result(运算比较简单 认真 已经给了编码 字节取反即可)01101(X)1010101011001011010101010010000010111110100111100(同 为()相 同 为0不 同 为1)
16、2.9 Computers 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:RGBColor000Black001Blue010Green011Cyan100Red101Magenta110Yellow111WhiteEach of these colors can be represented as a bit vector of length 3,and we can appl
18、y 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 of R,G and B.(取补)From this,we cansee
19、 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=Red A Magenta=Blue(001)I Green(010)=
20、Cyan(Oil)Yellow(110)&Cyan(011)=Green(010)Red(100)A Magenta(101)=Blue(001)2.10As an application of the property that a A a=0 for any bit vector a,consider the followingprogram:1 void inplace_swap(int*x,int*y)2*y=*x 八*y;/*Step 1 */3*x=*x 八 *y;/*Step 2*/4*y=*x 八 *y;/*Step 3*/5 As the name implies,we cl
21、aim 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 movingthe other.There is no performance adva
22、ntage 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 theproperties of A to show that the de
23、sired 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,you decide to write code that willreve
24、rse the elements of an array by swapping elements from opposite ends of the array,workingtoward the middle.(一个串倒序)You arrive 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_swap(&afirst,&alast);7When you appl
25、y 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,you discover that the code always work
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 云南大学 软件 学院 大二 年级 上册 学期 _ 专业 英语 重点 习题 总结
限制150内