当前位置:快学网资格考试计算机等级考试全国计算机三级考试数据库技术上机指导» 正文

全国计算机三级考试数据库技术上机指导

[04-06 18:27:19]   来源:http://www.kuaixue5.com  计算机等级考试   阅读:8150
概要: 概要:编写函数encryptChar()的程序内容如下:void encryptChar(){ int i, j, val ;for(i=0 ; ifor(j=0 ; jval=(xx[i][j]*11) % 256 ;if(! (val《=32 || val》130)) xx[i][j]=val ;}}数据文件IN.DAT内容如下:You may WANT A FIELD in field in each record to uniquely identify that1234record from all other records IN THE FILE. For example, the Employee123456Number field is unique if you DO NOT ASSIGN the same number to two12345678different employees, and you never reassign THESE NUMBERS to other12345678employees. If y
全国计算机三级考试数据库技术上机指导,标签:计算机等级考试试题,全国计算机等级考试试题,http://www.kuaixue5.com

编写函数encryptChar()的程序内容如下:

void encryptChar()

{ int i, j, val ;

for(i=0 ; i

for(j=0 ; j

val=(xx[i][j]*11) % 256 ;

if(! (val《=32 || val》130)) xx[i][j]=val ;

}

}

数据文件IN.DAT内容如下:

You may WANT A FIELD in field in each record to uniquely identify that1234

record from all other records IN THE FILE. For example, the Employee123456

Number field is unique if you DO NOT ASSIGN the same number to two12345678

different employees, and you never reassign THESE NUMBERS to other12345678

employees. If you wish to FIND OR MODIFY the record belonging to a11111111

specific employee, this unique FIELD SAVES the thouble of determining22222

whether you have the correct record.12345678901234567

If you do not have a unique field, YOU MUST FIND THE first record123456787

the matches your key and determine whether THEN RECORD is the one you33333

want. If it is not the CORRECT ONE, you must search again to find others.4

结果文件OUT.DAT内容如下:

Youm+3WAZTAF#EDDinbiWlLinW+AxrWAorLtouniquWl3iLWntib3tx+t1&1《rWAorLbrom+llotxWrrWAorLs#ZTHEF#DE.ForW(+mplW,txWEmplo3WW1&1

例2: 文件in.dat中有200个正整数,且每个数均在1000至9999之间。函数readDat()是读取这200个数存放到数组aa中。请编制函数jsSort(),其函数的功能是:要求按每个数的后三位的大小进行升序排列,将排序后的前10个数存入数组b中,如果数组b中出现后三位相等的数值,则对这些数值按原始4位数据进行降序排列。最后调用函数writeDat()把结果bb输出到文件out.dat中。

例:处理前 6012 5099 9012 7025 8088

处理后 9012 6012 7025 8088 5099

注意:部分源程序存在文件PROG1.C文件中。

请勿改动数据文件in.dat中的任何数据、主函数main()、读函数readDat()和写函数writeDat()的内容。

部分源程序如下:

#include

www.kuaixue5.com

#include

#include

int aa[200], bb[10] ;

void jsSort()

{

}

void main()

{

readDat() ;

jsSort() ;

writeDat() ;

}

readDat()

{

FILE *in ;

int i ;

in=fopen(“in.dat“, r) ;

for(i=0 ; i《200 ; i+[KG-*3]+) fscanf(in, “%d,“, &aa[i]) ;

fclose(in) ;

}

writeDat()

{

FILE *out ;

int i ;

clrscr() ;

out=fopen(“out.dat“, w) ;

for(i=0 ; i《10 ; i+[KG-*3]+) {

printf(“i=%d,%d\n“, i + 1,bb[i]) ;

fprintf(out, “%d\n“, bb[i]) ;

}

fclose(out) ;

}

分析:根据题意分析得出:本题主要考查考生的运用数组和排序的能力,要求考生仅编写函数jsSort实现此功能。其中输出函数给出且已调用,考生不必自己编写。

编写函数jsSort的程序如下:

void jsSort()

{

int i, j, m ;

for(i=0 ; i《199 ; i++)

for(j=i + 1 ; j《200 ; j++) {

if((aa[i] % 1000)》(aa[j] % 1000)) {

m=aa[i] ;

aa[i]=aa[j] ;

aa[j]=m ;

}

else if((aa[i] % 1000)= =(aa[j] % 1000)) {

if(aa[i]

m=aa[i] ;

aa[i]=aa[j] ;

aa[j]=m ;

}

}

}

for(i=0 ; i《10 ; i++) bb[i]=aa[i] ;

}

数据文件IN.DAT内容如下:

1862,8281,6183,5180,1217

8215,8865,7110,1870,4373

7447,8420,8252,8809,7968

7331,3472,4126,8101,5576

7397,2066,5940,9779,7947

2912,1226,2238,4122,6210

2020,3721,1646,8324,2351

2345,1862,5186,7573,8949

3211,2103,6695,7968,6157

9956,2998,4063,6096,9432

6452,2422,1382,5813,8138

7486,1178,7650,1687,5012

4845,1428,3197,6077,4650

6641,2695,5758,8855,5321

1337,5323,9154,6419,8044

3654,2246,1890,3250,5542

1976,5986,5051,8053,7377

3726,6189,9483,5874,9246

2522,1020,3492,4032,4367

9784,4746,3130,8521,7837

6521,7917,6240,1225,4092

8022,6893,2075,8043,7409

3316,5688,4600,6016,2953

6206,4100,8947,6264,1986

4933,6105,7054,9121,5318

3164,9609,5784,4178,4906

3731,2996,4218,3498,3849

3835,5491,3890,3531,1475

8219,3720,8585,9616,6539

4961,8850,5822,2769,1269

2171,2104,3681,9291,5768

3582,3035,7212,8313,5669

4782,7545,7917,8561,5447

4912,7624,1343,8579,5639

5745,1833,7948,4321,3090

9389,2796,8073,7806,4910

7970,2808,8109,8664,5963

3660,1396,1380,5705,7269

7417,5590,2823,6308,1754

5467,8126,9822,6737,1023

结果文件OUT.DAT的内容如下:

5012

6016

2020

1020

8022

1023

4032

3035

8043

8044

上一页  [1] [2] [3] 


Tag:计算机等级考试计算机等级考试试题,全国计算机等级考试试题计算机等级考试
上一篇:计算机三级考试网络技术之局域网应用技术

发表评论

表达一些您的想法吧!

文明评论,理性发言!

分类导航