当前位置:首页 >> 电流保险丝

计算机等级考试三级C语言上机试题总结下定向天线

2022-08-13 11:19:12  伟业五金网

计算机等级考试三级C语言上机试题总结(下)

计算机等级考试三级C语言上机试题总结(下) 2011: 英文文章——字符串处理(共10题)之一

code:/*函数ReadDat( )实现从文件IN.DAT中读取一篇英文文章存入到字符串数组xx中; 请编制函数SortCharD( ), 其函数的功能是: 以行为单位对字符按从大到小的顺序进行排序, 排序后的结果仍按行重新存入字符串数组xx中。最后main()函数调用函数WriteDat()把结果xx输出到文件OUT2.DAT中。例: 原文: dAe,BfC.CCbbAA结果: fedCBA.,bbCCAA原始数据文件存放的格式是: 每行的宽度均小于80个字符, 含标点符号和空格。

注意: 部分源程序存放在PROG1.C中。请勿改动主函数main( )、读数据函数ReadDat()和输出数据函数WriteDat()的内容。*/#include #include #include

char xx[50][80] ;int maxline = 0 ; /* 文章的总行数 */

int ReadDat(void) ;void WriteDat(void) ;

void SortCharD(void){/**/int i,j,k,m,n; char ch;for(i=0; i < maxline; i++){ j=strlen(xx[i]);for(m=0; m < j-1; m++){ k=m;for(n=m+1; n < j; n++)if(xx[i][k] < xx[i][n]) k=n;if(k!=m){ ch=xx[i][k]; xx[i][k]=xx[i][m]; xx[i][m]=ch; }}}

/**/}

void main(){clrscr() ;if(ReadDat()) {printf("数据文件IN.DAT不能打开!\n\007") ;return ;}SortCharD() ;WriteDat() ;}

int ReadDat(void){FILE *fp ;int i = 0 ;char *p ;

if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;while(fgets(xx[i], 80, fp) != NULL) {p = strchr(xx[i], '\n') ;if(p) *p = 0 ;i++ ;}maxline = i ;fclose(fp) ;return 0 ;}

void WriteDat(void){FILE *fp ;int i ;

clrscr() ;fp = fopen("OUT2.DAT", "w") ;for(i = 0 ; i < maxline ; i++) {printf("%s\n", xx[i]) ;fprintf(fp, "%s\n", xx[i]) ;}fclose(fp) ;}

in.dat 文件内容为:You can create an index on any field, on several fields to beusedtogether, or on parts thereof, that you want to use as a key.Thekeys in indexes allow you quick access to specific records anddefineorders for sequential processing of a ISAM file. After you nolongerneed an index, you can delete it. Addition and indexes have noeffecton the data records or on other indexes.You may want a field in field in each record to uniquelyidentify thatrecord from all other records in the file. For example, theEmployeeNumber field is unique if you do not assign the same number totwodifferent employees, and you never reassign these numbers tootheremployees. If you wish to find or modify the record belongingto aspecific employee, this unique field saves the thouble ofdeterminingwhether you have the correct record.If you do not have a unique field, you must find the firstrecordthe matches your key and determine whether the record is theone youwant. If it is not the correct one, you must search again tofind others.If you know that you have a unique field within your records,youcan include this fact in the key description, and ISAM willallow onlyunique keys. For example, if you specify that the employeenumbers areunique, ISAM only lets you add records to the file for, orchangenumbers to, employee numbers that do not alreadly exist intfile.

out2.dat 文件内容应当为:yxvuuttsssrroooonnnnnnllliiiffeeeeeeeeeddddccbaaaaaY,yywuuttttttttsssrrrrpoooooonnkhhhhgfeeeeeeeaaaaaT.,,yyxwuutssssssrrqpoooonnnnllkkiiiiiiffeeeeeeeeddddccccccaaayuuttssssrrrrrrqpooooooonnnnllliiiggffffeeeeeeedcaaSMIAA.yxxvuttttsooonnnnnnnnliiiiihffeeeeeeeeeeedddddddccaaaaA.,xtttssrrrrooooonnnihheeeeedddcaa.yyywuuutttttrrqooonnnnnmllliiiiiiihhfffeeeeeeddddccaaaaaYyxtttsrrrrrrrppoooooonmmmllllliihhhffeeeeeeeeeeddccaaFE.,ywuuuuuttttssssrrqooooonnnnmmmliiiiihgffeeeeeeddbbaaNyyvuuttttsssssrrrrrpoooonnnnnmmliihhgffeeeeeeeeeeeeddbaa,yyywutttssrrrpoooooooonnnmmlliiiihhggfffeeeeeedddcbaI.yvuuuttttssssrqppooonnnmmllliiiiiiihhhgfffeeeeeeeeeeeddccba,ywvu

治胃癌

上海白癜风医院医生

贵阳性病医院怎么样

昆明哪家不孕不育检查好

广州胰腺肿瘤医院

相关资讯
友情链接