更多"返回字符表达式的字符个数,当字符表达式为Null时,返回Null值的函"的相关试题:
[单项选择]使用哪个字符函数来返回一个值中字符的个数
A. NVL
B. SUBSTR
C. LENGTH
D. CONCAT
E. INITCAP
[简答题]请编写一个函数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)
//**********
[简答题]下列给定程序中,函数fun( )的功能是:从s所指字符串中,找出t所指字符串的个数作为函数值返回。例如,当s所指字符串中的内容为abcdabfab,t所指字符串的内容为ab,则函数返回整数3。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构.
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
int fun (char *s, char *t)
int n; char *p, *r;
n=0;
while(*s)
p=s;
r=t;
while (*r)
/**************found**************/
if(*r==*p) r++; p++
else break;
/*************found**************/
if(r==’/0’)
n++;
s++;
return n;
main( )
char s[100], t[100]; int m;
clrscr( );
printf("/nPlease enter string s: ");
scanf ("%s",s);
printf("/nPlease enter substring t: ");
scanf ("%s",t);
m=fun (s,t);
printf("/nThe result is: m=%d/n", m);
[简答题]编写函数fun,其功能是:求ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串”123412132”,输入字符为”1”,则输出3。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#define M 81
int fun(char*ss,char c)
int i=0;
for(;*ss!=’/0’;ss++)
if(*ss==c)
i++;/*求出ss所指字符串中指
定字符的个数*/
return 1:
void main( )
char a[M],ch;
system("CLS");
printf("/n Please enter a string:");
gets(a);
printf("/nPlease enter a char:");
ch=getchar( );
printf("/nThe number of the char is:%d/n",fun(a,ch));
[简答题]请编写函数fun,它的功能是:求出ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串:123412312,输入字符为1,则输出:3。
注意:部分源程序在文件PROG1.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
文件PROG1.C内容如下:
#include<stdio.h>
#include<string.h>
#define M 81
int fun(char *ss,char c)
void main( )
char a[M],ch;
printf("/nPlease enter a string: ");gets(a);
printf("/nPlease enter a char: ");ch=getchar( );
printf("/nThe number of the char is: %d/n",fun(a,ch));
[简答题]函数fun( )的功能是:从s所指字符串中,找出与t所指字符串相同的子串的个数作为函数值返回。例如,当s所指字符串中的内容为”abcdabfab”,t所指字符串的内容为”ab”,则函数返回整数3。
请改正程序中的错误,使它能得出正确的结果。
#include <stdio.h>
#include <string.h>
int fun(char *s,char *t)
int n;char *p,*r;
n=0;
while(*s)
p=s;r=t;
while(*r)
if(*r==*p)
/**********found**********/
r++;p++
else break;
/**********found**********/
if(r==’/0’)
n++;
s++;
return n;
main( )
char s[100],t[100];int m;
printf("/nPlease enter string S:");scanf("%s",s);
printf("/nPlease enter substring t:");scanf("%s",t);
m=fun(s,t);
printf("/nThe result is:m=%d/n",m);
[单项选择]字符函数Rtrim(字符表达式)返回去掉字符表达式什么的字符串
A. 前导空格
B. 中间空格
C. 两端空格
D. 尾部空格
[单项选择]返回一个值,该值是从字符表达式右侧第1个字符开始截取若干个字符的函数为
A. Space
B. String
C. Left
D. Right
[简答题]编写函数fun,其功能是:求ss所指字符串中指定字符的个数,并返回此值。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include < stdlib.h >
#include < conio .h >
#include < stdio.h >
#define M 81
int fun (char * ss, char c)
void main ( )
char a[M], ch;
system ("CLS");
printf (" / nPlease enter
string: ");
gets (a);
printf ("/nPlease enter a char:");
ch=getehar ( );
printf ("/nThe number of the char
is:% d/n", fun(a, ch));
[简答题]请编写函数fun( ),它的功能是:求出ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串123412132,输入字符1,则输出3。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<coio.h>
#include<stdio.h>
#define M 81
int fun(char *ss,char c)
{
}
main( )
{ char a[M],ch;
clrscr( );
printf("/nPlease enter a string:");
gets(a);
printf("/nPlease enter a char:");
ch=getchar( );
printf("/nThe number of the char is:%d /n",fun(a,ch));
}
[简答题]请编写函数fun( ),它的功能是:求出ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串123412132,输入字符1,则输出3。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<coio.h>
#include<stdio.h>
#define M 81
int fun(char *ss,char c)
main( )
char a[M],ch;
clrscr( );
printf("/nPlease enter a string:");
gets(a);
printf("/nPlease enter a char:");
ch=getchar( );
printf("/nThe number of the char is:%d /n",fun(a,ch));
[填空题]以下程序的功能是:通过函数func输入字符并统计输入字符的个数。输入时用字符@作为输入结
束标志。请填空。
#include
long 【 】 ;/* 函数说明语句 */
main( )
{long n;
n=func( );printf("n=%1d/n",n);
}
long func( )
{ long m;
for(m=0;getchar( )!=@;【 】);
return m;
}
[填空题]以下函数用来在w数组中插入x。n所指向的存储单元中存放w数组中字符个数。数组w中的字符已按从小到大的顺序排列,插入后数组w中的字符仍有序。请填空。
void fun(char*w,char x,int*n)
{ int i, p;
p=0;
w[*n]=x;
while(x>w[p])p++;
for(i=*n;i>p;i--)w[i]= 【13】 ;
w[p]=x;
++ *n;}