请补充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);
}
第1题
。高位仍在高位,低位仍在低位。例如,当s中的数为87653142时,t中的数为8642。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main,~数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <conio.h>
include <stdio.h>
void fun(long s,long *t)
/**********************************/
{ int d;
long s1=l;
*t=0;
while(s>0)
{ d=s%10;
/**********************************/
if(d%2=0)
{*t=d*sl+*t;
sl*=10
}
/**********************************/
s\=10;
}
}
main ( )
{ long s,t;
clrscr();
printf("\nPlease enter s: "); scanf
("%ld",&s);
fun(s,&t);
printf("The result is :%ld\n",t);
}
第2题
符串为asd asasdfg asd as zx67 asd mklo,子字符串为as,则应当输出6。
注意:部分源程序给出如下。
请勿改动主函数main和具他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <conio.h>
include <stdio.h>
include <string.h>
int fun(char *str, char *substr)
{
}
main ( )
{
char str[81],substr[3];
int n;
clrscr ();
printf ("输入主字符串 ");
gets (str);
printf ("输入子字符串");
gets (substr);
puts (str);
puts (substr);
n=fun (shr, substr);
printf("n=%d\n ",n);
}
第3题
下面程序的输出是【 】。
main()
{int arr[10],i,k=0;
for(i=0;i<10;i++)
arr[i]=i;
fov(i=1;i<4;i++)
k+=arr[i]+i;
printf("%d\n",k);}
第4题
以下程序运行后的输出结果是【10】。
include<stdio.h>
main()
{ char a;
for(a=0;a<15;a+=5)
{putchar(a+'A');}
printf("\n");
}
第7题
a,b,*p1,*p2; scanf("%d%d",&a,&B); p1=&a;p2=&b; if(a<B)swap(p1,p2); printf("\na=%d,b=%d\n",a,B); } 若a=7,b=8,则程序的运行结果为( )。
第8题
作为结束输入的标志)。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<conio.h>
include<stdio.h>
include<string.h>
fun(char (*a) [81], int num, char *max)
{
}
main ()
{
char ss[l0] [81],*ps;
int n, i=0;
clrscr();
prlntf("输入若干个字符串");
gets(ss[i]);
puts(ss[i]);
while(!strcmp(ss[i], "****")==0)
/*用****作为结束输入的标志*/
{
i++;
gets(ss[i]);
puts(ss[i]);
}
n=i;
ps=fun(ss,n,&ps);
print~("\nmax=%s\n",ps);
}
第9题
契数列是一整数数列,该数列自第三项开始,每数等于前面两数之和,即0,1,1,2,3,5,8,13,21,34,55,…。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdio.h>
int fun(int n);
main()
{
int i,n=0;
scanf("%d",&n);
for(i=0;i<n; i++)
printf("%d",fun(i));
}
int fun(int n)
{
if(【 】)
return 0;
else
if(【 】)
return 1;
else
return【 】;
}
第10题
序,并输出排序结果。ss所指字符串数组中共有N个字符串,且串长小于M。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANKl.C中。
不得增行或删行,也不得更改程序的结构!
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!