题目内容

试题三 (共15 分 )
阅读以下说明和C 函数,将应填入 (n) 处的字句写在答题纸的对应栏内。
【说明】
基于管理的需要,每本正式出版的图书都有一个 ISBN 号。例如,某图书的 ISBN号为“978-7-5606-2348-1”。
ISBN 号由 13 位数字组成:前三位数字代表该出版物是图书(前缀号),中间的 9个数字分为三组,分别表示组号、出版者号和书名号,最后一个数字是校验码。其中,前缀号由国际EAN提供,已经采用的前缀号为978和979;组号用以区别出版者国家、地区或者语言区,其长度可为1~5位;出版者号为各出版者的代码,其长度与出版者的计划出书量直接相关;书名号代表该出版者该出版物的特定版次;校验码采用模10加权的算法计算得出。
校验码的计算方法如下:
第一步:前 12 位数字中的奇数位数字用 1 相乘,偶数位数字用 3 相乘(位编号从左到右依次为13到2);
第二步:将各乘积相加,求出总和S;
第三步:将总和S 除以10,得出余数R;
第四步:将10减去余数R后即为校验码V。若相减后的数值为10,则校验码为0。
例如,对于ISBN 号“978-7-5606-2348-1”,其校验码为1,计算过程为:
S=9×1+7×3+8×1+7×3+5×1+6×3+0×1+6×3+2×1+3×3+4×1+8×3=139
R = 139 mod 10 = 9
V = 10 – 9 = 1
函数check(char code[])用来检查保存在code中的一个ISBN号的校验码是否正确,若正确则返回 true,否则返回 false。例如,ISBN 号“978-7-5606-2348-1”在 code 中的存储布局如表3-1所示(书号的各组成部分之间用“-”分隔):
在函数check(char code[])中,先将13位ISBN号放在整型数组元素tarr[0]~tarr[12]中(如表3-2 所示,对应 ISBN 号的位13~位 1),由 tarr[0]~tarr[11]计算出校验码放入变量V,再进行判断。
【 C 函数 】
bool check(char code[])
{
int i, k = 0;
int S = 0, temp = 0;
int V;
int tarr[13] = {0};
if (strlen(code) < 17) return false;
for(i=0; i<17; i++ ) /* 将13位ISBN 号存入tarr */
if (code[i]!= '-' )
tarr[ (1) ] = code[i] - '0' ;
for(i=0; (2) ; i++ ) {
if (i%2 )
S += (3) ;
else
S += (4) ;
}
V = ((5) == 0 )? 0 : 10 - S %10;
if (tarr[12] == V)
return true;
return false;
}

查看答案
更多问题

我国的改革开放30年来,经济增长和科学进步的巨大步伐在相当程度上改变了世界经济竞争格局。()

团队合力,是团队精神形成的基础。()

在沟通过程中,领导者的个人风格和领导者的个性特征、管理风格相关,并且,领导者的个人风格与沟通的相关度非常高。()

From what has been said, it must be clear that no one can
make very positive statements about how language originated.
There is no material in any language today and in the earliest (1)
records of ancient languages show us language in a new and (2)
emerging state. It is often said, of course, that the language (3)
originated in cries of anger, fear, pain and pleasure, and the (4)
necessary evidence is entirely lacking: there are no remote
tribes, no ancient records, providing evidence of
a language with a large proportion of such cries (5)
than we find in English. it is true that the absence
of such evidence does not disprove the theory, but in (6)
other grounds too the theory is not very attractive.
People of all races and languages make rather similar
noises in return to pain or pleasure. The fact that(7)
such noises are similar on the lips of Frenchmen
and Malaysians whose languages are utterly different,
serves to emphasize on the fundamental difference(8)
between these noises and language proper. We may
say that the cries of pain or chortles of amusement
are largely reflex actions, instinctive to ∧ large extent, (9)
whereas language proper does not consist of signs
but of these that have to be learnt and that are (10)

答案查题题库