更多"请编写函数fun( ),它的功能是:求出ss所指字符串中指定字符的个数"的相关试题:
[简答题]请编写函数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( ),它的功能是:求出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));
}
[简答题]请编写一个函数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)
//**********
[填空题]下列程序的功能是:求出ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串123412132,指定字符1,则输出3。请填空。
#include<stdio.h)
#deftne M 81
int fun(char * ss,char c)
int i=0;
for(; ;ss++)
if(*ss==c) i++;
return i;
main( )
char a[M],ch;
printf("//nPlease enter a string:");gets(a);
printf("//nPlease enterachar:");ch=getchar( );
printf("//nThe number of the char is:%d//n",fun(a,ch));
[填空题]下列程序的功能是:求出ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串123412132,指定字符1,则输出3。请填空。
#include<stdio.h)
#deftne M 81
int fun(char * ss,char c)
int i=0;
for(; 【18】 ;ss++)
if(*ss==c) i++;
return i;
main( )
char a[M],ch;
printf("/nPlease enter a string:");gets(a);
printf("/nPlease enterachar:");ch=getchar( );
printf("/nThe number of the char is:%d/n",fun(a,ch));
[填空题]下列程序的功能是:求出ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串123412132,输入字符1,则输出3,请填空。
#include<conio.h>
#include<stdio.h>
#define M 81
int fun(char*ss,char c)
{int i=0;
for(;______;ss++)
if(*ss==c)i++;
return i;}
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));}
[填空题]下列程序的功能是:求出ss所指字符串中指定字符的个数,并返回此值。例如,若输入字符串123412132,指定字符1,则输出3。请填空。
#include<conio.h>
#include<stdio.h>
#define M 81
int fun(char *ss,char c)
int i=0;
for(;______;ss++)
if( *ss==c)i++:
return i;
main( )
char a[M],ch;
printf("/nPlease enter a string:");gets(a);
printf("/nPlease enter a char:");ch=getchar( );
prinff("/nThe number of the char is:%d/n",fun(a,ch));
[简答题]请编写一个函数fun( ),其功能是比较两个字符串的长度(不得调用C语言提供的求字符串长度的函数),函数返回较长的字符串。若两个字符串长度相同,则返回第一个字符串。
例如,输入beijing<CR>shanghai<CR>(<CR>为回车键),函数将返回shanghai。
#include<stdio.h>
char*fun(char*s,char*t)
main( )
char a[20],b[20];
void NONO( );
printf("Input 1th string:");
gets(a);
printf("Input 2th string:");
gets(b);
printf("%s/n",fun(a,b));
[简答题]编写函数fun,其功能是:求ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串“123412132”,输入字符为“1”,则输出3。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<sfdlib.h>
#include<conio.h>
#include<sfdio.h>
#define M 81
int fun(char*SS,char C)
void main( )
char a[M],ch;
system("CLS");
printfl(/nPlease enter a string:");
getsia);
printf("/nPlease enter a char:");
ch=getchar( );
printf("/nThe number of the char is:%d/n",fun(a,ch));
[简答题]请编写函数fun( ),其功能是:将s所指字符串中下标为偶数的字符删除,串中剩余字符形成的新串放在t所指数组中。
例如,当s所指字符串中的内容为ABCDEFGHIJK,则在t所指数组中的内容应是BDFHJ。
注意:部分源程序给出如下。
请勿改动主函数main口其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio. h>
#include<stdio .h>
#include<string.h>
void fun(char *s,char t[])
{
}
main ( )
char s[l00] ,t[l00];
clrscr ( );
printf("%nPlease enter string S: ");
scanf("%s ",s);
fun(s,t);
prlntf("/nThe result is:%s/n ",t);
}
[简答题]请编写一个函数char *fun(char *s),其中s代表一个字符串。函数fun( )的功能是将字符串s的元素倒置。例如,输入为“teacher”,则应输出“rehcaet”。
注意:部分源程序已存在文件PROC10.cpp中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句。
文件PROC10.cpp的内容如下:
//PROC10. cpp
#include <iostream>
#include <string>
using namespace std;
char *fun(char *s);
int main ( )
char str[81];
cout<<"Please enter a string:/n";
cin>>str;
cout<<"The result is:"<<fun(str));
cout<<end1;
return 0;
char*fun(char*s)
//* * * * * * * * *