请编写函数fun,该函数的功能是:将两个两位数的正整数a、b合并形成一个整数放在c中。合并方式是:将a
请编写函数fun(),该函数的功能是:将两个两位数的正整数a,b合并形成一个整数放在c中。合并的方式是:将a数的十位和个位数依次放在c数的十位和千位上,b数的十位和个位数依次放在c数的百位和个位上。
例如,当a=45时,b=12,调用到该函数后,c=5142。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <stdio.h>
include<conio.h>
void fun(int a ,int b, long *c)
{
}
main ()
{
int a,b;
long c;
clrscr();
printf("Input a ,b:");
scanf(,%d%d",&a,&b);
fun(a,b,&c);
printf("The result is :%ld\n",c);
}
请编写一个函数fun(),它的功能是:比较两个字符串的长度,(不得调用C语言提供的求字符串长度的函数),函数返回较K的字符串。若两个字符串长度相等,则返回第1个字符串。
例如,输入beijing<CR>shanghai<CR>(<CR>为回车键),函数将返回shanghai。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<stdio.h>
char *fun(char *s, char *t)
{
}
main()
{
char a[20],b[10],*p,*q;
int i;
printf ("Input 1th string: ");
gets(a);
printf{"Input 2th string: ");
gets(b);
printf("%s",fun(a,b));
}
请编写一个函数void fun(int m, int k, int xx[]),该函数的功能是:将大于整数m且紧靠m的k个素数存入所指的数组中。
例如,若输入17,5,则应输出19,23,29,3l,37。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <conio.h>
include <stdio.h>
void fun(int m, int k, int xx[])
{
}
main()
{
int m,n, zz[1000];
clrscr();
printf("\nPlease enter two integers: ");
scanf("%d%d",&m,&n);
fun(m,n,zz);
for(m=O;m<n;m++)
printf("%d ",zz[m]);
printf("\n ");
}
请编写函数fun(),该函数的功能是:将放在字符串数组中的M个字符串(每串的长度不超过N),按J顷序合并组成一个新的字符串。
例如,若字符串数组中的M个字符串为
AAAA
BBBBBBB
CC
则合并后的字符串内容应该是AAAABBBBBBBCC
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <conio. h>
define M 3
define N 20
void fun (char a [M] [N], char *b)
{
}
main ()
{
char w [M] [N] ={"AAAA", "BBBBBBB", "CC"}, i;
char a[100]={" "};
printf ("The string: \n ");
for (i=0; i<M; i++)
puts (w[i]);
printf (" \n ");
fun (w, a);
printf ("The A string: \n ");
printf("%s ",a);
printf("\n\n ");
}
请编写函数fun(),该函数的功能是:将s所指字符串中 ASCII值为偶数的字符删除,串中剩余字符形成一个新串放在t所指的数组中。
例如,若s所指字符串中的内容为ABCDEFGl2345,其中字符B的ASCⅡ码值为偶数、…、字符2的ASCⅡ码值为偶数、…,都应当删除,其他依次类推。最后t所指的数组中的内容应是ACEGl35。
注定:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序;
include <stdio. h>
include<string.h>
include<conio. h>
void fun(char *s, char t[])
{
}
main ()
{
char s[100],t [100];
clrscr ();
printf (,\nPlease enter string S: ");
scanf ("%s", s);
fun(s,t);
printf ("\nThe result is :%s\n",t);
}
请编写一个函数fun,其功能是:将两个两位数的正整数ab合并形成一个整数放在c中。合并方式是:将a数的十位和个位数依次放在c数的个位和百位上,b数的十位和个位数依次放在c数的十位和千位上。
●试题四
请补充函数fun(),该函数的功能是将字符串tt中的大写字母都改为对应的小写字母,其他字符不变。例如,若输入"Are you come from Sichuan?",则输入"are you come from sichuan?"。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<string.h>
#include<conio.h>
char *fun(char tt[])
{
int i;
for(i=0;tt[i];i++)
{
if((tt[i]>=′A′)&&((1) ))
(2) ;
}
return ((3) ) ;
}
main()
{
char tt[81];
printf("\nPlease enter a string:");
gets(tt);
printf("\nThe result string is: \n%s",
fun(tt));
}
请编写函数fun(),该函数的功能是:将M行N列的二维数组中的字符数据,按列的顺序依次放到一个字符串中。
例如,若二维数组中的数据为:
W WWW
S S S S
H H H H
则字符串中的内容应是WSHWSHWSHWSH。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<stdio.h>
define M 3
define N 4
void fun(char (*s)[N],char *b)
{
}
main()
{
char a[100],w[M][N]={{ 'W', 'W', 'W', 'W'},
{'S', 'S', 'S', 'S'},{'H', 'H', 'H', 'H'}};
int i,j;
printf("The matrix:\n");
for(i=0;i<M;i++)
{ for(j=0;j<N;j++)
printf("%3c",w[i][j]);
printf("\n");
}
fun(w,a);
printf("The A string:In");
puts(a);
printf("\n\n");
}
请编写函数fun(),该函数的功能是将M行N列的二维数组中的数据,按列的顺序依次放到一维数组中。
例如:二维数组中的数据为
33333333
44444444
55555555
则一维数组中的内容应是
334455334455334455334455。
注意:部分源程序以存在文件test_2.cpp中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
文件test39_2.cpp的内容如下:
include<stdio.h>
include<iostream.h>
void fun(int(*s) [10],int *b, int *n,int mm,int nn)
{
}
void main()
{
int w[10][10]={{33,33,33,33},{44,44,44,44},{55,55,55,55}},i,j;
int a[100]={0}, n=0;
cout<<"The matrix:\n"
for(i=0; i<3; i++)
{
for(j=0; j<4; j++
cout<<w[i] [j];
cout<<endl;
}
fun(w, a, &n, 3, 4);
cout<<"The A array:\n";
for(i=0; i<n; i++)
cout<<a[i];
cout<<"\n\n";
}
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!