Hottest level II C computer simulation test questi

2022-09-24
  • Detail

Level 2 C on-line simulation test questions and answers (5)

function readdat() reads an English article from a file and stores it in the

string array XX; Please compile the function comword() to calculate the word length of 2,4,

6,8 and the total number of words respectively, and store them in the integer array yy[0] to yy[4] in turn,

finally call the function writedat() to output the result YY to the file t

the format of storing the original data file is: the width of each line is less than 80 characters, including

punctuation and spaces

note: some source programs are stored in prog1 C. Words in each line of the article are separated from single

words by spaces or other punctuation marks, and each word is less than 20 characters

do not change the contents of the main function main(), the read data function readdat() and the output data function

number writedat()

/* refer to the answer */

include

include

include

include

include

char xx[50][80]

int yy[5] ;

int maxline = 0 ;/* The total number of lines in the article */

int readdat (void)

void WriteDat(void) ;

void comword (void)

{

int I, J, K, N, len, s[4] = {2,4,6,8}

char word[20],c;

memset(yy,0,5*sizeof(int));

for(i = 0; i maxline; i++)

{

len = strlen(xx);

n = 0;

for(j = 0; j len+1; j++)

{

c = xx[j];

if((c ='a' c ='z') || (c ='A' c ='Z'))

{

word[n] = c;

n++;

}

else

{

word[n] = '';

if(word[0] != '')

{

for(k = 0; k k++)

if(n == s[k])

yy[k]++;

yy[4]++;

}

n = 0;

}

}

}

}

void main()

{

int I;

clrscr();

for (I = 0; I I I i++) YY = 0;

if (readdat()) {

printf ("data file cannot be opened! n07");

return;

}

comword()

WriteDat() ;

}

int ReadDat(void)

{

FILE *fp ;

int i = 0 ;

char *p ;

if((fp = fopen("", "r")) == NULL) return 1 ;

while(fgets(xx, 80, fp) != NULL) {

p = strchr(xx, 'n') ;

if(p) xx[p - xx] = 0 ;

i++ ;

}

maxline = i ;

fclose(fp) ;

return 0 ;

}

void writedat (void)

{

file *fp;

int I;

fp = fopen ("t", "W");

for (I = 0; I I i++) fprintf (FP, ""%dn ", YY);

printf (" number of words with word length of 3 =%dn ", yy[0];

printf (" word length is 5 words =%dn ", yy[1];

printf (" words with word length of 7 =%dn ", yy[2]);

printf (" words with word length of 9 =%dn ", yy[3]) ;

printf ("total number of words =%dn", yy[4])

fclose(fp) ;

}

var arrBaiduCproConfig=new Array(); arrBaiduCproConfig['uid'] =120380; arrBaiduCproConfig['n'] ='lw365cpr'; arrBaiduCproConfig['tm'] =30; arrBaiduCproConfig['cm'] =34; arrBaiduCproConfig['um'] =28; arrBaiduCproConfig['w'] =468; arrBaiduCproConfig['h'] =60; arrBaiduCproConfig['wn'] =2; arrBaiduCproConfig['hn'] =1; arrBaiduCproConfig['ta'] ='right'; arrBaiduCproConfig['tl'] ='bottom'; arrBaiduCproConfig['bu'] =0; arrBaiduCproConfig['bd'] ='#trans'; Therefore, the oil pipe connection of the force adding part and the force measuring part will be affected by both. 3. When installing this experimental machine, please place it on a solid bottom cabinet or concrete foundation. The positional and vertical deviation of the installation is affected config['bg'] ='trans'; arrBaiduCproConfig['tt'] ='#0000ff'; arrBaiduCproConfig['ct'] ='#444444'; arrBaiduCproConfig['url'] ='#008000'; ARRB can ensure the good level operation of the experimental machine aiducproconfig['bdl'] ='00000'; arrBaiduCproConfig['rad'] =0;

Copyright © 2011 JIN SHI