2016最新計(jì)算機(jī)三級(jí)網(wǎng)絡(luò)上機(jī)試題及答案
函數(shù)ReadDat( )實(shí)現(xiàn)從文件IN.DAT中讀取一篇英文文章存入到字符串?dāng)?shù)組xx中; 請(qǐng)編制函數(shù)SortCharD( ), 其函數(shù)的功能是: 以行為單位對(duì)字符按從大到小的順序進(jìn)行排序, 排序后的結(jié)果仍按行重新存入字符串?dāng)?shù)組xx中。最后main()函數(shù)調(diào)用函數(shù)WriteDat()把結(jié)果xx輸出到文件OUT2.DAT中。
例: 原文: dAe,BfC.
CCbbAA
結(jié)果: fedCBA.,
bbCCAA
原始數(shù)據(jù)文件存放的格式是: 每行的寬度均小于80個(gè)字符, 含標(biāo)點(diǎn)符號(hào)和空格。
注意: 部分源程序存放在PROG1.C中。
請(qǐng)勿改動(dòng)主函數(shù)main( )、讀數(shù)據(jù)函數(shù)ReadDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。
-----------------
PROG1.C
#include
#include
#include
char xx[50][80] ;
int maxline = 0 ; /* 文章的總行數(shù) */
int ReadDat(void) ;
void WriteDat(void) ;
void SortCharD(void)
{int I,j,k,strl;
char ch;
for(I=0;I
{strl=strlen(xx[I]);
for(j=0;j
for(k=j+1;k
if(xx[I][j]
{ch=xx[I][j]; xx[I][j]=xx[I][k]; xx[I][k]=ch;}
}
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("數(shù)據(jù)文件IN.DAT不能打開!\n\007") ;
return ;
}
SortCharD() ;
WriteDat() ;
system("pause");
}
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
dAe,BfC.
CCbbAA
You can create an index on any field, on several fields to be used
together, or on parts thereof, that you want to use as a key. The
keys in indexes allow you quick access to specific records and define
orders for sequential processing of a ISAM file. After you no longer
need an index, you can delete it. Addition and indexes have no effect
on the data records or on other indexes.
You may want a field in field in each record to uniquely identify that
record from all other records in the file. For example, the Employee
Number field is unique if you do not assign the same number to two
different employees, and you never reassign these numbers to other
employees. If you wish to find or modify the record belonging to a
specific employee, this unique field saves the thouble of determining
whether you have the correct record.
If you do not have a unique field, you must find the first record
the matches your key and determine whether the record is the one you
want. If it is not the correct one, you must search again to find others.
If you know that you have a unique field within your records, you
can include this fact in the key description, and ISAM will allow only
unique keys. For example, if you specify that the employee numbers are
unique, ISAM only lets you add records to the file for, or change
numbers to, employee numbers that do not alreadly exist int file.
OUT.DAT
fedCBA.,
bbCCAA
yxvuuttsssrroooonnnnnnllliiiffeeeeeeeeeddddccbaaaaaY,
yywuuttttttttsssrrrrpoooooonnkhhhhgfeeeeeeeaaaaaT.,,
yyxwuutssssssrrqpoooonnnnllkkiiiiiiffeeeeeeeeddddccccccaaa
yuuttssssrrrrrrqpooooooonnnnllliiiggffffeeeeeeedcaaSMIAA.
yxxvuttttsooonnnnnnnnliiiiihffeeeeeeeeeeedddddddccaaaaA.,
xtttssrrrrooooonnnihheeeeedddcaa.
yyywuuutttttrrqooonnnnnmllliiiiiiihhfffeeeeeeddddccaaaaaY
yxtttsrrrrrrrppoooooonmmmllllliihhhffeeeeeeeeeeddccaaFE.,
ywuuuuuttttssssrrqooooonnnnmmmliiiiihgffeeeeeeddbbaaN
yyvuuttttsssssrrrrrpoooonnnnnmmliihhgffeeeeeeeeeeeeddbaa,
yyywutttssrrrpoooooooonnnmmlliiiihhggfffeeeeeedddcbaI.
yvuuuttttssssrqppooonnnmmllliiiiiiihhhgfffeeeeeeeeeeeddccba,
ywvutttrrrrrooohhhheeeeeedccca.
yyvuuuuuttttssrrrqooooonnnmliiiihhffffeeeeeddddcaaI,
yyywuuttttttssrrrrroooonnnmmkiihhhhhheeeeeeeeeeeedddccaa
ywuuttttttttssssrrrroooooonnnnnmiiiihhhgffeeeeedcccaaaaI..,
yyyywwvuuuuuutttsrrrqoooooonnnlkiiiihhhffeeeeddcaaaI,
yywwuttttssrpooonnnnnnllllllkiiiiiihhfeeeedddccccaaaaSMIA,
yyyyxuuuutttsssrrrqpppooonnmmmllkiiihhffeeeeeeeeeeecbaaaF.,
yyuuutttssrrrrqoooooonnnllliihhgffeeeeeedddccaaSMIA,,
yyxuuttttttsssrrrpoooonnnnmmmlllliiihfeeeeeeeeddbbaaa.
【最新計(jì)算機(jī)三級(jí)網(wǎng)絡(luò)上機(jī)試題及答案】相關(guān)文章:
最新計(jì)算機(jī)三級(jí)網(wǎng)絡(luò)技術(shù)上機(jī)試題及答案09-04
2016最新三級(jí)網(wǎng)絡(luò)技術(shù)上機(jī)試題及答案08-20
2016最新計(jì)算機(jī)三級(jí)Access上機(jī)試題及答案08-30
計(jì)算機(jī)三級(jí)Access上機(jī)試題及答案07-01
最新計(jì)算機(jī)三級(jí)網(wǎng)絡(luò)試題及答案09-10
計(jì)算機(jī)網(wǎng)絡(luò)三級(jí)上機(jī)考試題及答案07-04
計(jì)算機(jī)三級(jí)上機(jī)試題09-24