當前位置:成語大全網 - 新華字典 - 大神幫忙寫壹篇C語言程序設計綜合性實驗

大神幫忙寫壹篇C語言程序設計綜合性實驗

#include?<stdio.h>

#include?<string.h>

#include?<ctype.h>

#define?MAXSIZE?36

struct?Word?{

char?word[MAXSIZE];

unsigned?size;

}words[10000];

int?n?=?0;

void?Sort()?{

//?沒有時間寫了

}

void?Additive(char?word[])?{

int?i,flag?=?1;

for(i?=?0;?i?<?n?&&?flag;?++i)?{

if(strcmp(words[i].word,word)?==?0)?{

++words[i].size;

flag?=?0;

}

}

if(flag)?{

strcpy(words[n].word,word);

words[n].size?=?1;

++n;

}

}

int?main()?{

int?i,ch;

char?word[MAXSIZE];

FILE?*fin?=?fopen("case1.in","rt");

if(fin?==?NULL)?{

printf("無法打開數據文件!\n");

return?1;

}

i?=?0;

while((ch?=?fgetc(fin))?!=?EOF)?{

if(isalpha(ch))?word[i++]?=?tolower(ch);

else?if(i)?{

word[i]?=?'\0';

i?=?0;

Additive(word);

}

}

if(i)?{

word[i]?=?'\0';

Additive(word);

}

fclose(fin);

Sort();

return?0;

}