更多"填空题
请补充main函数,该函数的功能是:把一个字符串中的所有小写"的相关试题:
[简答题]填空题
请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]=“123 abcdef ABCDEF!”,结果输出:“123 ABCDEF ABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#include
#define N 80
void main( )
{
int j;
char str[N]=" 123abcdef ABCDEF!";
char *pf=str;
clrscr( );
printf("***original string ***/n");
puts(str);
【1】;
while(*(pf+j))
{
if(*(pf+j)>=’’a’’&&*(pf+j)<=’’z’’)
{
*(pf+j)=【2】;
j++;
}
else
【3】;
}
printf("******new string******/n");
puts(str);
system("pause");
}
[填空题]请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]“123 abcdef ABCDEF!”,结果输出:
“123ABCDEFABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define N 80
void main( )
int j;
char str[N]="123abcdef ABCDEF!";
char *pf=str;
clrscr( );
printf("*** original string ***/n");
puts(str);
【1】 ;
while(*(pf+j)).
if(*(pf+j)>=’a’&&* (pf+j)<=’z’)
*(pf+j)= 【2】 ;
j++;
else
【3】 ;
printf("****** new string ******/n");
puts(str);
system("pause");
[简答题]填空题
请补充函数fun( ),该函数的功能是:把一个整数转换成字符串,并倒序保存在字符数组str中。例如:当n=13572468时,str=“86427531”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#define N 80
char str[N];
void fun(long int n)
{
int i=0;
while(【1】)
{
str[i]=【2】;
n/=10;
i++;
}
【3】;
}
main( )
{
long int n=13572468;
clrscr( );
printf("*** the origial data ***/n");
printf("n=%ld",n);
fun(n);
printf("/n%s",str);
}
[简答题]填空题
请补充函数fun( ),该函数的功能是:把从主函数中输入的字符串str2倒置后接在字符串str1后面。
例如:str1=“How do”,str2=“od uoy”,结果输出:“How do you do”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#define N 40
void fun(char *str1,char *str2)
{
int i=0,j=0,k=0,n;
char ch;
char *p1=str1;
char *p2=str2;
while(*(p1+i))
i++;
while(*(p2+j))
j++;
n=【1】;
for(;k<=j/2;k++,j--)
{
ch=*(p2+k);
*(p2+k)=*(p2+j);
*(p2+j)=ch;
}
【2】;
for(;【3】;i++)
*(p1+i)=*p2++;
*(p1+i)=’’/0’’;
}
main( )
{
char str1[N],str2[N];
int m,n,k;
clrscr( );
printf("***Input the string str1 & str2
***/n");
printf("/nstr1:");
gets(str1);
printf("/nstr2:");
gets(str2);
printf("*** The string str1 & str2 ***/n");
puts(str1);
puts(str2);
fun(str1,str2);
printf("*** The new string ***/n");
puts(str1);
}
[多项选择]填空题
请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则str2=“cegi”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#define LEN 80
main( )
{
char str1[LEN],str2[LEN];
char *p1=str1,*p2=str2;
int i=0,j=0;
clrscr( );
printf("Enter the string:/n");
scanf(【1】);
printf("***the origial string***/n");
while(*(p1+j))
{
printf("【2】",*(p1+j));
j++;
}
for(i=0;i
[简答题]填空题
请补充函数fun( ),该函数的功能是:把字符串str中的字符按字符的ASCII码降序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传入。
例如,如果输入“cdefgh”,则输出为“hgfedc”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#define N 80
void fun(char s[],int n)
{
int i, j;
char ch;
for(i=0;i
[简答题]填空题
请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在b[10]中。
例如:当str1=“ab123456789cde090”时,结果为:
0:2 1:1 2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:2 other charactor:5
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
main( )
{
int i,b[11];
char *str="ab123456789cde090";
char *p=str;
clrscr( );
printf("*** the origial data ***/n");
puts(str);
for(i=0;i<11;i++)
b[i]=0;
while(*p)
{
switch(【1】)
{
case ’’0’’:b[0]++;break;
case ’’1’’:b[1]++;break;
case ’’2’’:b[2]++;break;
case ’’3’’:b[3]++;break;
case ’’4’’:b[4]++;break;
case ’’5’’:b[5]++;break;
case ’’6’’:b[6]++;break;
case ’’7’’:b[7]++;break;
case ’’8’’:b[8]++;break;
case ’’9’’:b[9]++;break;
【2】
}
【3】
}
printf("****** the result ********/n");
for(i=0;i<10;i++)
printf("/n%d:%d",i,b[i]);
printf("/nother charactor:%d",b[i]);
}
[简答题]填空题
请补充函数fun( ),该函数的功能是:按‘0’到‘9’统计一个字符串中的奇数数字字符各自出现的次数,结果保存在数组num中。注意:不能使用字符串库函数。
例如:输入“x=112385713.456+0.909*bc”,结果为:1=3,3=2,5=2,7=1,9=2。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#define N 1000
void fun(char *tt,int num[])
{
int i,j;
int bb[10];
char *p=tt;
for(i=0;i<10;i++)
{
num[i]=0;
bb[i]=0;
}
while(【1】)
{
if(*p>=’’0’’&&*p<=’’9’’)
【2】;
p++;
}
for(i=1,j=0;i<10;i=i+2,j++)
【3】;
}
main( )
{
char str[N];
int num[10],k;
clrscr( );
printf("/nPlease enter a char string:");
gets(str);
printf("/n**The original string**/n");
puts(str);
fun(str,num);
printf("/n**The number of letter**/n");
for(k=0;k<5;k++)
{
printf("/n");
printf("%d=%d",2*k+1,num[k]);
}
printf("/n");
return;
}
[简答题]填空题
str是一个由数字和字母字符组成的字符串,由变量num传入字符串长度。请补充函数fun( ),该函数的功能是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。
例如:str=“Bcd123e456hui890”,结果为:123456890。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#define N 80
int bb[N];
int fun(char s[],int bb[],int num)
{
int i,n=0;
for(i=0;i
[填空题]请补充函数fun( ),该函数的功能是:把从主函数中输入的由数字字符组成的字符串转换成—个无符号长整数,并且逆序输出。结果由函数返回。
例如,输入: 1 2 3 4 5 6,结果输出:6 5 4 3 2 1。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<conio.h>
#include<stdio.h>
#include<string.h>
unsigned long fun(char *s)
{
unsigned long t=0;
int k;
int i=0;
i=strlen(s);
for( 【1】 ;i>=0;i--)
{
k= 【2】 ;
t= 【3】 ;
}
return t;
}
main( )
{
char str[8];
clrscr( );
printf("Enter a string made up of’0’to
’9’digital character:/n");
gets(str);
printf("The string iS:%S/n",str);
if(strlen(str)>8)
printf("The string is too long!");
else
printf("The result:%lu/n",
fun(str));
}
[简答题]请编写一个函数fun( ),该函数的功能是:返回给定字符串中大写字母字符的个数。
如字符串"Hello World"中,大写字母的个数为2个。
注意:部分源程序已存在文件PROC5.CPP中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句。
文件PROC5.cpp的内容如下:
//PROC5.cpp
#include<iostream>
#include<string>
using namespace std;
int fun(char *str);
int main( )
{
char str[ ]="Chinese Computer World";
cout<<fun(str)<<end;
return 0;
}
int fun(char *str)
{
//**********
}
[简答题]请编写一个函数fun( ),该函数的功能是:返回给定字符串中大写字母字符的个数。
如字符串"Hello World"中,大写字母的个数为2个。
注意:部分源程序已存在文件PROC5.CPP中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句。
文件PROC5.cpp的内容如下:
//PROC5.cpp
#include<iostream>
#include<string>
using namespace std;
int fun(char *str);
int main( )
char str[ ]="Chinese Computer World";
cout<<fun(str)<<end;
return 0;
int fun(char *str)
//**********