2005~2011年全国计算机二级C语言机试题库
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
double fun(int m)
{
double t=1.0;
int I;
for(I=2;I<=m;I++)
/*************found**************/
t+=1.0/k;
/*************found**************/
return I;
}
void main()
{int m;
system("CLS");
printf("\nPlease enter 1integer number: ");
scanf("%d",&m);
printf("\nThe result is %1f\n", fun(m));
}
【参考答案】
(1)错误:t+=1.0/k; 正确:t+=1.0/I;
(2)错误:return I; 正确:return t;
下列给定程序中,函数fun的功能是:分别统计字符串中大写字母和小写字母的个数
。例如,给字符串s输入:AaaaBBb123CCccccd,则应输出结果:upper=5,lower=9。 请改正程序中的错误,使它能计算出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<conio.h>
#include<stdio.h>
/*********found***********/
void fun(char *s,int a,int b)
{
while(*s)
{
/*********found***********/
if(*s>='A' && *s<='Z')
a++;
/*********found***********/
if(*s>='a' && *s<='z')


