更多"请补充main函数,该函数的功能是:从键盘输入3个整数,然后找出最大的"的相关试题:
[填空题]请补充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)
【1】 ;
else
【2】 ;
if(max<c)
【3】 ;
printf("max=%d/n",max);
[填空题]请补充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)
【1】 ;
else
【2】 ;
if(max<c)
【3】 ;
printf("max=%d/n",max);
}
[填空题]请补充主函数main( ),该函数的功能是:把从键盘输入的3个整数按从小到大输出。
例如,输入“50 60 40”,结果输出“40 50 60”。
注意:部分源程序给出如下。
请勿改动main( )函数和其他函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void main( )
{
int x,y,z,s;
system("CLS");
printf("Input x,y,z/n");
scanf("%d%d%d",&x,&y,&z);
if(______)
{
s=x;
x=y;
y=s;
}
//交换x,y的值
if(______)
{
s=z;
z=x;
x=s;
}
//交换x,z的值
if(______)
{
s=y;
y=z;
z=s;
}
//交换z,y的值
printf("****the result****/n");
printf("from small to big:%d%d%d/n",x,y,z);
}
[填空题]请补充main函数,该函数的功能是:从键盘输入一组整数,使用条件表达式找出最大的整数。当输入的整数为0时结束。
例如,输入1,2,3,5,4,0时,最大的数为5。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写出的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 100
main( )
int num[N];
int i=-1;
int max=0;
clrscr( );
printf("/nInput integer number:/n");
do
i++;
printf("num[%d]=",i);
scanf("%d", 【1】 );
max= 【2】 num[i]:max;
while ( 【3】 );
printf("max=%dkn",max);
[填空题]请补充main函数,该函数的功能是:从键盘输入只有两个整数参与运算的一个四则运算式,然后计算出它的值。注意数字全部为正整数。
例如,输入308*28,结果为8624.000000。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
# include<stdio, h>
main ( )
int a=0, b=0, flag=l, fg=l;
float result;
char *p, ch;
char str[10];
clrscr ( );
printf("/n Input a string /n");
gets (str);
p=str;
while (*p)
if (*p>=’0’ &&*p<=’9’ && flag==l )
a= 【1】 ;
else
if (fg)
ch=*p;
flag=2;
fg=0;
if (*p>=’0 ’ &&*p<=’9’ &&flag==2)
b= 【2】 ;
p++;
switch( 【3】 )
case ’+’: result=a+b;break;
case ’-’: result=a-b;break;
case ’*’ :result=a*b;break;
case ’/’ :result= (float) a/b;break;
printf ("/nresult=%f", re
[填空题]请补充main函数,该函数的功能是:从键盘输入一个长整数,如果这个数是负数,则取它的绝对值,并显示出来。
例如,输入:-3847652,结果为:3847652。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
main( )
long int n;
clrscr( );
printf("Enter the data;/n");
scanf( 【1】 );
printf("*** the absolute value ***/n");
if(n<0)
【2】
printf("/n/n");
printf( 【3】 );
[填空题]请补充main函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的所有字符全部删除。结果仍然保存在原串中。
例如,输入“abcdef”,指定字符为‘e’,则输出“abcd”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio. h>
#define N 80
main ( )
int i=0;
char str [N];
char ch;
clrscr ( );
printf"/n Input a string:/n");
gets (str);
printf("kn Input a charator;/n");
scanf ("%c", &ch);
while (str [i] !=’/0’)
if (str [i]==ch)
【1】
【2】 ;
str[i]= 【3】 ;
printf"/n*** display string ***/n");
puts (str);
[填空题]请补充main函数,该函数的功能是:从键盘输入若干字符放到一个字符数组中,当桉回车键时结束输入,最后输出这个字符数组中的所有字符。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<ctype.h>
main( )
{
int i=0;
char a [81];
char *p=s;
clrscr ( );
printf{" Input a string /n");
for (i=0; i<80; i++)
{
s [i] =getchar ( );
if (s [i]==’/n’)
【1】;
}
s[i]= 【2】
printf(" display the string /n");
while (*p)
putchar (【3】 );
}
[多项选择]填空题
请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则str2=“cegi”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#define LEN 80
main( )
{
char str1[LEN],str2[LEN];
char *p1=str1,*p2=str2;
int i=0,j=0;
clrscr( );
printf("Enter the string:/n");
scanf(【1】);
printf("***the origial string***/n");
while(*(p1+j))
{
printf("【2】",*(p1+j));
j++;
}
for(i=0;i
[填空题]请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则 str2=“cegi”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define LEN 80
main( )
char str1[LEN],str2 [LEN];
char *p1=str1,*p2=str2;
int i=0,j=0;
clrscr( );
printf("Enter the string:/n");
scanf( 【1】 );
printf("***the origial string***/n");
while(*(p1+j))
printf(" 【2】 ",*(p1+j));
j++;
for(i=0;i<j;i+=2)
*p2++=*(str1+i);
*p2=’/0’;
printf("/nThe new string is:%s/n", 【3】 );