考试首页 | 考试用书 | 培训课程 | 模拟考场 | 考试论坛  
全国  |             |          |          |          |          |         
  当前位置:计算机等级 > 二级考试 > C语言程序设计 > C语言模拟试题 > 文章内容
  

全国计算机等级考试C语言考试程序设计题(6)

中华IT学院   【 】  [ 2016年6月6日 ]

在考生文件夹下,要求程序PROG.C的功能是:

求字符串的长度并输出。

    例如,当字符串1为"This Is a c Program"

          则应输出:Result is: 19

 

  #include

  int fun(char str[])

  {

  /***********begin***********/

int i=0;

  while(str[i]!='\0')

  {

         i++;

  }

  return i;

 

 

 

 

 

 

 


int i=0,s=0;

for(i=m;i<=n;i++)

if(1%3!==0)

 s=s+i;

return s;

  /************end************/

  }

  void main()

  {

    void NONO( );   //函数声明

    char str1[80]="This Is a c Program";

    int count;

    printf("String is: %s\n",str1);

    count=fun(str1);

    printf("Result is: %d\n",count);

    NONO( );

  }

 

  void NONO( )

  { FILE  *fr,*fw;

    int i,j;

    char s1[80];

    fr=fopen("PROGIN.DAT","r");

    fw=fopen("PROGOUT.DAT","w");

    for(i=1;i<=5;i++)

    { fscanf(fr,"%s",s1);

      fprintf(fw,"%d\n",fun(s1));

    }

    fclose(fr);

    fclose(fw);

  }

 

分享到:
本文纠错】【告诉好友】【打印此文】【返回顶部
将考试网添加到收藏夹 | 每次上网自动访问考试网 | 复制本页地址,传给QQ/MSN上的好友 | 申请链接 | 意见留言 TOP
关于本站  网站声明  广告服务  联系方式  站内导航  考试论坛
Copyright © 2006-2017 中华考试网(Examw.com) All Rights Reserved  营业执照