在考生文件夾下,要求程序PROG.C的功能是:
統(tǒng)計(jì)字符串中英文字母的個數(shù)并輸出。
例如,當(dāng)字符串為"This Is a c Program"
輸出:Result is:15
#include
#include
fun(char str1[])
{
/***********begin***********/
int i=0,s=0; while(str1[i]!='\0') { if((str1[i]>='a' && str1[i]<='z') || (str1[i]>='A' && str1[i]<='Z')) s++; i++; } return s; |
/************end************/
}
void main()
{
void NONO( );//函數(shù)聲明
char str1[80];
int n;
printf("Enter str1:\n");
gets(str1);
n=fun(str1);
printf("Result is: %d\n",n);
NONO( );
}
void NONO( )
{ FILE *fr,*fw;
int i;
char s[80];
fr=fopen("PROGIN.DAT","r");
fw=fopen("PROGOUT.DAT","w");
for(i=1;i<=5;i++)
{ fgets(s,80,fr);
fprintf(fw,"TheResultis:%d\n",fun(s));
}
fclose(fr);
fclose(fw);
}
![]() | ![]() .. 定價:¥225 優(yōu)惠價:¥213 更多書籍 |
![]() | ![]() .. 定價:¥133 優(yōu)惠價:¥133.0 更多書籍 |