
求大佬指点,C语言
#include<string.h>#include<stdio.h>intspace,other;voidfun(charstr[]){/***********begi...
#include <string.h>
#include <stdio.h>
int space,other;
void fun(char str[])
{
/***********begin***********/
int i;
for(i=0;i<80;i++)
{
if(str[i]=' ')
space++;
else
other++;
}
return(space);
return(other);
/***********end************/
}
int main()
{
void NONO( ); //函数声明
char str[80];
printf("Input string:\n");
gets(str);
fun(str);
printf("空格:%d,非空格:%d\n",space,other);
NONO();
return 0;
}
void NONO( )
{ FILE *fr,*fw;
int i;
char s[80];
fr=fopen("E:\\exam\\999999\\PROGIN1.DAT","r");
fw=fopen("E:\\exam\\999999\\PROGOUT1.DAT","w");
space=other=0;
for(i=1;i<=5;i++)
{ fgets(s,80,fr);
space=other=0;
fun(s);
fprintf(fw,"空格:%d,非空格:%d\n",space,other);
} fclose(fr);
fclose(fw);
} 展开
#include <stdio.h>
int space,other;
void fun(char str[])
{
/***********begin***********/
int i;
for(i=0;i<80;i++)
{
if(str[i]=' ')
space++;
else
other++;
}
return(space);
return(other);
/***********end************/
}
int main()
{
void NONO( ); //函数声明
char str[80];
printf("Input string:\n");
gets(str);
fun(str);
printf("空格:%d,非空格:%d\n",space,other);
NONO();
return 0;
}
void NONO( )
{ FILE *fr,*fw;
int i;
char s[80];
fr=fopen("E:\\exam\\999999\\PROGIN1.DAT","r");
fw=fopen("E:\\exam\\999999\\PROGOUT1.DAT","w");
space=other=0;
for(i=1;i<=5;i++)
{ fgets(s,80,fr);
space=other=0;
fun(s);
fprintf(fw,"空格:%d,非空格:%d\n",space,other);
} fclose(fr);
fclose(fw);
} 展开
1个回答
展开全部
#include <string.h>
#include <stdio.h>
int space,other;
void fun(char str[])
{
/***********begin***********/
int i;
for(i=0;str[i];i++)
{
if(str[i]==' ')
space++;
else
other++;
}
/***********end************/
}
int main()
{
void NONO( ); //函数声明
char str[80];
printf("Input string:\n");
gets(str);
fun(str);
printf("空格:%d,非空格:%d\n",space,other);
NONO();
return 0;
}
void NONO( )
{ FILE *fr,*fw;
int i;
char s[80];
fr=fopen("E:\\exam\\999999\\PROGIN1.DAT","r");
fw=fopen("E:\\exam\\999999\\PROGOUT1.DAT","w");
space=other=0;
for(i=1;i<=5;i++)
{ fgets(s,80,fr);
space=other=0;
fun(s);
fprintf(fw,"空格:%d,非空格:%d\n",space,other);
} fclose(fr);
fclose(fw);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询