请补充main函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的
请补充main函数,该函数的功能是:从键盘输入3个整数,然后找出最大的数并输出。
例如,输入:12,45,43,最大值为45。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdio.h>
include<conio.h>
main()
{
int a, b, c, max;
clrscr();
printf("\nlnput three numbers:\n");
scanf("%d,%d,%d",&a,&b,&c);
printf("The three numbers are:%d,
%d,%d\n",a,b,c);
if(a>b)
【 】;
else
【 】;
if(max<c)
【 】;
printf("max=%d\n",max);
}
请补充函数proc(),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。
例如,str1=”I am a”,str2=”student”,结果输出:I am a student。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
请补充函数proc(),该函数的功能是把数组num中的数按从小到大的顺序排列(数组元素个数及值从主函数中输入)。
例如,输入n=5,num[0]~num[4]依次为5 7 2 8 0,结果为0 2 5 7 8。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
例如,输入:-3847652,结果为:3847652。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdio.h>
include<conio.h>
main()
{
long int n;
clrscr();
printf("Enter the data;\n");
scanf(【 】);
printf("*** the absolute value ***\n");
if(n<0)
【 】
printf("\n\n");
printf(【 】);
}
请补充函数fun(),该函数的功能是:把ASCⅡ码为偶数的字符从字符串s打中删除,结果仍然保存在字符串srt中,字符串str从键盘输入,其长度作为参数传入函数fun()。
例如,输入“abcdef”,输出“ace”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
inc lude< stdio, h>
define N 80
【 】
{
int i, j;
【 】
for (i=0;i<n;i++)
{
if (s [i] %2!=0)
s [j++]=s [i];
}
【 】;
}
main ()
{
int i=0, strlen=0;
char str[N];
clrscr ();
printf ("\nInput a string:\n");
gets (str);
while (str [i] !=' \0' )
{
strlen++;
i++;
}
fun (str, strlen);
printf("\n*** display string ***\n");
puts (str);
}
请补充函数fun(),该函数的功能求能整除x且是偶数的数,把这些数保存在数组bb中,并按从大到小的顺序输出。
例如当x=20时,依次输出:20 10 4 2。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include<conio.h>
include<stdio.h>
void fun(int k,int bb[ ])
{
int i;
int j=0;
for(【l】;i<=k;i++)
{
if(【 】)
bb[i++]=i;
}
printf("\n\n");
for(i=【 】;i>=0;i--)
printf(“%d”,bb[i]);
}
main()
{
int k=1;
int bb[100];
clrscr();
printf(“\nPlease input X=”);
scanf(“%d”,&k);
fun(k,bb);
}
请补充函数fun(),该函数的功能是;删除字符数组中小于等于指定字符的字符,指定字符从键盘输入,结果仍保存
例如,输入“abcdefghij”,指定字符为‘d’,则结果输出“defghij”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include <stdio. h>
define N 80
void fun (char s[], char ch)
{
int i=0, j=0;
while (s [i] )
{
if (s Iii<ch)
【 】;
else
{
【 】
i++;
}
}
【 】
}
main ()
{
char str [N], ch;
clrscr ();
printf("\n Input a string:\n");
gets (str);
printf("\n*** original string ***\n");
puts (str);
printf("\n Input a character:\n");
scanf ("%c", &ch);
fun(str, ch);
printf("\n*** new string ***\n");
puts (str);
}
请补充函数fun(),该函数的功能是:把字符下标为非素数的字符从字符串sb中删除,把字符下标为素数的字符重新保存在字符串e口中。字符串sb从键盘输入,其长度作为参数传入函数fun()。
例如,输入“abcdefghijkl”,输出“cdfhl”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
include <stdio.h>
define N 80
void fun(char s[],int n)
{
int i, j, k, flag;
【 】;
for(i=0; i<n; i++)
{
if (i>1)
s [k++] =s [i];
flag=I;
for(【 】; j<i&&flag; j++)
if (i%j==0)
{
flag=0;
【 】
}
}
s [k]='\0';
}
main()
{
int i=0, strlen=0;
char str[N];
clrscr ();
printf("\n Input a string:\n");
gets (str);
while (str [i] !='\0')
{
strlen++;
i++;
}
fun (str, strlen);
printf("\n*** display string ***\n");
puts (str);
}
请补充函数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(【 】;i>=0;i--)
{
k=【 】;
t=【 】;
}
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));
}
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!