当前位置: 代码迷 >> C语言 >> 帮忙给解释一下!
  详细解决方案

帮忙给解释一下!

热度:135   发布时间:2007-03-31 15:30:40.0
帮忙给解释一下!







#include <stdio.h>
#include <string.h>
void fun(char *a, int b[])
{
int i;
for (i=0; i<6; i++) b[i] = 0;
for (i=0; i< strlen(a); i++)
if (a[i] >= 'a' && a[i] <= 'e') b[a[i] - 'a']++;
else b[5]++;
}

main()
{ int i, b[6]; char a[100] = "bacd1b+ddep";
fun(a, b);
printf("The result is: ");
for (i=0; i<6; i++) printf("%d ", b[i]);
printf("\n");
NONO();
}
NONO()
{/* 本函数用于数据读入和结果写入文件, 考生无需修改 */
FILE *rf, *wf ;-------------------------
char a[100], *p ;----------------------
int b[6], i, j ;------------------------------
rf = fopen("in.dat", "r") ;-----------------------
if(rf == NULL) {------------
printf("在考生文件夹下数据文件in.dat不存在!") ;----------
return ;
}
wf = fopen("out.dat", "w") ;---------------
for(i = 0 ; i < 10 ; i++) {------------
fgets(a, 99, rf) ;---------------------------
p = strchr(a, '\n') ;---------
if(p) *p = 0 ;-----------
fun(a, b) ;------------------
for(j = 0 ; j < 6 ; j++) fprintf(wf, "%d ", b[j]) ;--------
fprintf(wf, "\n") ;-----------
}------------
fclose(rf) ;-----------
fclose(wf) ;-------
}
请在"------"后加解释


[此贴子已经被作者于2007-3-31 15:41:13编辑过]

搜索更多相关的解决方案: 解释  

----------------解决方案--------------------------------------------------------
3Q
----------------解决方案--------------------------------------------------------