文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > 资格考试/认证 > IT认证 > 全国计算机等级考试二级上机南开100题
侵权投诉

全国计算机等级考试二级上机南开100题

全国计算机等级考试二级上机南开100题

void fun (char *str,char ch) {

while (*str &&*str !=ch) str++; if(*str【1】ch) { str[0]=ch; 【2】=0; } }

void main() {char s[81],c; system("CLS");

printf("\nPlease enter a string : "); gets(s);

printf("\n Please enter the character to search : "); c=getchar(); fun(【3】);

printf("\nThe result is %s\n",s); }

【参考答案】 (1) != (2) str[1]或*(str+1) (3) s,c 【考点分析】 本题考查:if语句,一般掌握条件表达式的判定。函数的调用,其一般形式为"函数名(实际参数表)"。 【解题思路】

填空1:根据题意"若相同什么也不做",则应填入!=。

填空2:若不同则插在串的最后,那么0就在字符串的倒数第二了。 填空3:函数传递的参数为输入的两个字符串,则填入s,c。

下列给定程序中,函数fun的功能是:分别统计字符串中大写字母和小写字母的个数。例如,给字符串s输入:AaaaBBb123CCccccd,则应输出结果:upper=5,lower=9。

6

注意:不要改动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') b++; s++; } }

main() {

char s[100];

int upper=0,lower=0;

printf("\nplease a string :"); gets(s);

fun(s,&upper,&lower);

printf("\n upper=%d lower=%d\n",upper,lower); }

【参考答案】

上一页第6页

你可能喜欢

热门文档

相关文档

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email