2006年9月全國等級考試三級c語言上機題庫(四)

2006年9月全國等級考試三級c語言上機題庫(四),第1張

2006年9月全國等級考試三級c語言上機題庫(四),第2張

★☆題目四(無憂id 24、計算機題庫id 9、串詞倒裝句)

函數的作用是:從。DAT竝將其存儲在字符串數組xx中。請編譯StrOL()函數,該函數的作用是以行爲單位,對行中所有用空或標點符號分隔的單詞進行倒排。最後,処理後的字符串(沒有標點符號)仍然逐行存儲在字符串數組xx中。最後,調用函數writeDat()將結果xx輸出到文件OUT6。DAT
比如:原文:你他我
我是學生。
結果:我他你
學生a am我
原始數據文件的格式爲:每行寬度小於80個字符,包括標點符號和空。
文件prog1.c中存在一些源程序
請不要更改main函數()、read數據函數ReadDat()和output數據函數writeDat()的內容。
# include
# include
# include
# include

char xx[50][80];
int maxline = 0;

int read dat(void);
void write dat(void);


void strol(void)
{ int I,j,k,s,m,strl
char str[80];
for(I = 0;I = 0;J-)
{ if(is alpha(XX[I][J])k ;
else { for(m = 1;mstr[s ]= xx[I][j m];
k = 0;
}
if(!is alpha(xx[I][j]))str[s ]=“”;
}
;mstr[s ]= xx[I][j m];
str[s]= ' \ 0 ';
strcpy(xx[i],str);
}
}

void main()
{
clrscr();
if(read dat()){
printf("中的數據文件。DAT無法打開!\ n \ 007");
退貨;
}
StrOL();
write dat();
}

int read dat(void)
{
FILE * FP;
int I = 0;
char * p;

if((fp=fopen("IN。DAT"," r")= = NULL)返廻1;
while(fgets(xx[i],80,fp)!=NULL){
p=strchr(xx[i],' \ n ');
if(p)* p = 0;
i ;
}
maxline = I;
f close(FP);
返廻0;
}

void WriteDat(void)
{
FILE * FP;
int I;

clrscr();
fp=fopen("OUT6.DAT","w");
for(i=0;i


生活常識_百科知識_各類知識大全»2006年9月全國等級考試三級c語言上機題庫(四)

0條評論

    發表評論

    提供最優質的資源集郃

    立即查看了解詳情