题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-23 03:33:43

[多项选择]请编写函数proc( ),它的功能是:求出str所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串12341234123,输入字符4,则输出2。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#define N 81
int proc(char * str, char c)


void main( )
char a[N], ch;
system("CLS");
printf("/nPlease enter a string: ");
gets(a);
printf("/nPlease enter a char: ");
ch=getchar( );
printf("/nThe number of the char is: %d /n", proc(a, ch));

更多"请编写函数proc( ),它的功能是:求出str所指字符串中指定字符的"的相关试题:

[简答题]请编写一个函数proc( ),它的功能是:比较两个字符串的长度(不得调用C语言中求字符串长度的函数),函数返回较长的字符串。若两个字符串长度相等,则返回第1个字符串。
例如,若输入jiangxi<CR>
beijing<CR>(<CR>为回车键)
则函数返回jiangxi。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在函数proc的花括号中填入所编写的若干语句。
试题程序:
#include<stdio.h>
char * proc(char *s, char *t)


void main( )

char a[20], b[10], *p, *q;
printf("Input 1th string: ");
gets(a);
printf("Input 2th string: ");
gets(b);
printf("%s", proc(a,b));

[多项选择]请编写函数proc( ),该函数的功能是:将放在字符串数组中的M个字符串(每串的长度不超过N),按顺序合并组成一个新的字符串。
例如,若字符串数组中的M个字符串为:
A. 则合并后的字符串内容应该是BCDEFGCDEFGHI
B. void main()char str[M][N]=("", "BCDEFG", "CDEFGHI"), i;
[简答题]请编写一个函数proc( ),它的功能是:将str所指字符串中所有下标为奇数位置的字母转换为大写(若该位置上不是字母,则不转换)。
例如,若输入abcde123, 则应输出aBcDe123。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void proc(char*str)


void main( )

char tt[81];
system ("CLS");
printf("/nPlease enter an string within 80 characters: /n");
gets(tt);
printf("/n/nAfter changing, the string / %s", tt);
proc(tt);
printf("/nbecomes/n %s/n", tt);

[简答题]假定输入的字符串中只包含字母和*号。请编写函数proc( ),它的功能是:只删除字符串前导和尾部的*号,串中字母之间的*号都不删除。形参m给出了字符串的长度,形参h给出了字符串中前导*号的个数,形参e给出了字符串中最后*号的个数。在编写函数时,不得使用c语言提供的字符串函数。
例如,若字符串中的内容为****a*bc*def*g*******,删除后,字符串中的内容则应当是a*bc*def*g。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdio.h>
#include<conio.h>
void proc(char*a, int m, int h, int e)


void main( )

char s[81], *t, *f;
int m=0, tn=0, fn=0;
printf("Enter a string: /n");
gets(s);
t=f=s;
while(*t)
t++; m++; ) //m为字符串的长度
t--; //指针t指向字符串尾部
while(*t==’*’)
t--; tn++;
//指针t指向最后一个字母,tn统计尾部’*’的个数
while(*f==’*’)
f++; fn++;
//指针f指向第一个字母,tn统计前导’*’的个数
proc(s, m, fn, tn);
printf("The string after deleted: /n");
puts(s); )
[填空题]下面的函数strcat(str1,str2)实现将字符串str2拼接到字符串str1后面的功能。请填空使之完整。 char*strcat(str1,str2) char*str1,*str2; { char*t=str1; while( 【16】 )str1++; while( 【17】 ); return(t);}
[简答题]请编写函数proc( ),函数的功能是求出二维数组周边元素之和,作为函数值返回。二维数组中的值在主函数中赋予。
例如,若二维数组中的值为:
0 1 2 3 4
5 9 7 4 5
4 3 8 3 6
3 5 6 8 7
则函数值为59。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在函数proc的花括号中填入所编写的若干语句。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#define M 4
#define N 5
int proc(int a[M][N])


void main( )

int aa[M]EN]=0, 1, 2, 3, 4, 5, 9, 7.4, 5,
4, 3, 8, 3, 6, (3, 5, 6.8, 7;
int i, j, y;
system("CLS");
printf("The original data is: /n");
for(i=0; i<M; i++)
for(j=0; j<N; j++)
printf("%6d", aa[i][j]);
printf("/n");

y=proc(aa);
printf("/nThc sun: %d/n", y);
printf("/n");

[简答题]下列程序定义了M×M的二维数组,并在主函数中赋值。请编写函数proc( ),函数的功能是:求出数组周边元素的平均值并作为函数值返回给主函数中的s。例如,若a数组中的值为:
a=0 1 2 3 4
5 9 7 4 5
4 3 8 3 6
3 5 6 8 7
2 1 0 9 8
则返回主程序后,S的值为3.750000。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define M 5
double proc(int w[][M])


void main( )

int a[M][M]=0, 1, 2, 3, 4, 5, 9, 7, 4, 5, 4, 3, 8, 3, 6, 3, 5, 6, 8, 7, 2, 1, 0, 9, 8;
int i, j;
double s;
system("CLS");
printf("*****The array*****/n");
for(i=0; i<M; i++)
for(j=0; j<M; j++)
printf("%4d", a[i][j]);
printf("/n");

s=proc(a);
printf("*****THE RESULT*****/n");
printf("The sum is: %lf/n", s);

[填空题]请补充main函数,该函数的功能是:把字符串str1中的非空格字符拷贝到字符串str2中。 例如,若sffl=“glad to see you!”, 则str2=“gladtoseeyou!”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #define N 80 main( ) { static char strl [N] ="glad to see you!"; char str2 IN]; int i=0, j=0; clrscr ( ); printf("/n***** strl*****/n "); puts (str1); while (str1 [i] ) { if(【1】) str2 [J++] =strl [i]; 【2】; } printf("/n***** str2 *****/n "); for (i=0; i<j; i++) printf ("%c", str2 [i] ); }
[填空题]请补充函数fun( ),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。
例如:str1=“How do”,str2=“you do”,结果输出:How do you do
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 40
void fun(char *str1,char *str2)

int i=0;
char *p1=str1;
char *p2=str2;
while( 【1】 )
i++;
for( ; 【2】 ;i++)
*(p1+i)= 【3】
*(p1+i)=’/0’;
main( )

char str1[N],str2[N);
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);

[简答题]请编一个函数fun(char*str),该函数的功能是把字符串中的内容逆置。
例如,字符串中原有的字符串为asdfg,则调用该函数后,串中的内容为gfdsa。
请勿改动主函数rllain和其他函数中的任何内容,仅在函数proc的花括号中填入所编写的若干语句。
试题程序:
#include<string.h>
#include<conio.h>
#include<stdio.h>
#define N 100
void fun(char*str)

char a[N];
FILE*out;
printf("Enter a string:");
gets(a);
printf("The original string is:");
puts(a);
fun(a);


main( )
printf("The string after modified:");
puts(a);
strcpy(a,"Welcome!");
fun(a);
out=fopen("outfile.dat","w");
fprintf(out,"%s",a);
fclose(out);

[填空题]请补充函数fun( ),该函数的功能是:把从主函数中输入的字符串str2倒置后接在字符串str1后面。 例如:str1=“How do”,str2=“od uoy”,结果输出:“How do you do”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #include<conio.h> #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函数,该函数的功能是:把字符串str中的字符向前移动一位,原来的第一个字符移动到字符串尾,结果仍然保存在原字符串中。
例如,输入“how do you do”,则结果输出“ow do you doh”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio. h>
#define N 80
main( )

char str[N], ch;
int i;
clrscr ( );
printf("/n Input a string:In");
gets (str);
printf("/n*** original string ***In");
puts (str);
ch=str [0];
for (i=0; 【1】 ; i++)
str [i]=str [i+1];
【2】 ;
printf("/n *** new string ***/n");
puts (str);

[填空题]在给定程序中,函数fun的功能是:求出形参SS所指字符串数组中最长字符串的长度,其余字符串左边用字符*补齐,使其与最长的字符串等长。字符串数组中共有M个字符串,且串长<N。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。
文件BLANK1.C内容如下:
#include<stdio.h>
#include<string.h>
#define M 5
#define N 20
void fun(char( *ss)[N])
int i,j,k=0,n,m,len;
for(i=0;i<M;i++)
len=strlen(ss[i]);
if(i==0)n=len:
if(len>n)
/**********found**********/
n=len;
(1) =i;


for(i=0;i<M;i++)
if(i!=k)
m=n:
len=strlen(ss[i]);
/***********found***********/
for(j= (2) ;j>=0;j--)ss[i][m--]=ss[i][j];
for(j=0;j<n-len;j++)
/**********found**********/
(3) =’*’:

void main( )
char ss[M][N]="shanghai","guangzhou","beijing","tianjing","cchongqing";
int i;
printf("/nThe original strings are: /n");
for(i=0;i<M;i++)printf("%s/n",ss[i]);
printf("/n");
fun(ss);
printf("/nThe resuh

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码