首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列给定程序中,fun函数的功能是:分别统计字符串中大写字母和小写字母的个数。 例如,给字符串s输入:AAaaBBbb123 CCcccd,则应输出: upper=6,lower=8。请改正程序中的错误,使它得出正确的结果。 注意:
下列给定程序中,fun函数的功能是:分别统计字符串中大写字母和小写字母的个数。 例如,给字符串s输入:AAaaBBbb123 CCcccd,则应输出: upper=6,lower=8。请改正程序中的错误,使它得出正确的结果。 注意:
admin
2017-09-23
20
问题
下列给定程序中,fun函数的功能是:分别统计字符串中大写字母和小写字母的个数。
例如,给字符串s输入:AAaaBBbb123 CCcccd,则应输出:
upper=6,lower=8。请改正程序中的错误,使它得出正确的结果。
注意:部分源程序在文件MODI1.C中,不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include < stdio.h >
/*********found*********/
void fun ( char *s, int a, int b )
{
whiie (*s )
if(*s >=’A’&&* s < =’Z’)
/*********found*********/
*a=a+1;
if(*s >=’a’&& S < =’z’)
/*********found*********/
s ++ ;
}
}
main ( )
{ char s[100]; int upper = 0,
lower = 0 ;
printf ( "\nPlease a string : " ) ;
gets ( s );
fun ( s, & upper, &lower );
printf ( " \ n uppelr =% d lower
=%d\n", upper, lower ) ;
}
选项
答案
(1)void fun(char *s,int *a,int *b) (2)*a=*a+1; (3)*b=*b+1;
解析
(1)由主函数中调用fun函数的语句fun(s, &upper,&lower)可知,函数的后两个变量为指针的形式,所以用*a和*b。
(2)*a的作用是用来记录大写字母的个数,此处的作用是对*a累加1,所以此处应改为*a=*a+1。
(3)*b的作用是用来记录小写字母的个数,此处的作用是对*b累加1,所以此处应改为*b=*b+1。
转载请注明原文地址:https://kaotiyun.com/show/Wzxp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下选项中,当x为大于1的奇数时,值为0的表达式为()。
C语言源程序名的后缀是()。
有以下程序:#include<stdio.h>#defineN8voidfun(int*x,inti){*x=*(x+i)+1;}main(){inta[N]={1,2,3,4,5,6,7,8},i
若x=2,y=3,则x&y的结果是()。
下面程序运行后的输出结果是()。#include<stdio.h>main(){inta[5]={1,0,4,2,0},b[5]={1,2,3,4,5},i,s=0;for(i=0;i<5;i++)s=s+b[a[
下列4个程序中,完全正确的是()。
下面程序将二维数组a的行和列元素互换后存放到另一个二维数组b中,请填空。main(){inta[2][3]={{1,2,3},{4,5}},b[3][2],i,j;for(i=0;i<2;i++){for(j=0;j<3;j++)
阅读以下程序#include<stdio.h>main(){IntCase;floatprintF;printf("请输入2个数:");scanf("%d%f",&Case,&printF);print
以下语句定义正确的是()。
若已定义的函数有返回值,则以下关于该函数调用的叙述中错误的是()。
随机试题
心肺复苏时首选的给药途径是
A.左主干B.左旋支干C.左前降支D.右前降支冠心病心肌梗死最常发生在哪支冠状动脉的供血区?
下列各项中不属于佝偻病的初期临床表现的是
(2006年考试真题)如果用认股权证购买普通股,则股票的购买价格一般()。
社会工作者要同服务对象进行复杂的、面对面的沟通、互动和协作,要与政府部门、社会公众接触与合作,应该具有良好的处理人与人的关系、促进合作的能力。这种处理具体问题的动手能力是指()。
教师的________是教师胜任教学工作的基础性要求。
患者,男,30岁。主诉发热,身目发黄,恶心呕吐10余天。一个月前,曾因公事出差,在此期间,有过多次暴饮暴食。15天后,归家途中便有腹部胀满,疲乏无力之表现。又半月后,突然恶寒发热,两目白睛及全身肌肤皆发黄,其黄如橘色,小便亦黄赤如茶。经一般治疗未效(诊断及
综合布线工程包括哪3个主要环节?指出该承建单位制订的操作规程中的不正确之处。
下列程序段运行结束后,变量x的值是( )。x=2y=2Do x=x*y y=y+1LoopWhiley<4
Afterthebirthofmysecondchild,Igotajobatarestaurant.Havingworkedwithanexperienced【C1】______forafewdays,Iwa
最新回复
(
0
)