更多"请补充main函数,该函数的功能是:从键盘输入只有两个整数参与运算的一"的相关试题:
[填空题]请补充函数fun( ),该函数的功能是:把从键盘输入的3个整数按从小到大输出。
例如:输入“33 78 25”,结果输出“25 33 78”。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun 的横线上填入所编写的若干表达式或语句。
试题程序:
# include<stdio. h>
# include<conio. h>
main( )
{
int x,y, z,t;
clrscr ( );
printf ("Input x, y, z/n");
scanf ("%d%d%d", &x, &y, &z);
if( 【1】 )
{
t=x;
x=y;
y=t;
}/*变换x, y的值*/
if( 【2】 )
t=z;
z=x;
x=t;
}/*交换x, z 的值*/
if( 【3】 )
{
t=y;
y=z;
z=t;
}/*变换 z, y 的值*/
printf("******the result*******/n");
printf("from small to big: %d %d %d/n",
x, y, z);
}
[填空题]请补充函数fun( ),该函数的功能是:返回字符数组中指定子符的个数,指定字符从键盘输入。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#define N 80
int fun (char s[],char ch)
int i=0, n=0;
while( 【1】 )
if( 【2】 )
n++;
i++;
【3】 ;
main ( )
int n;
char str[N], ch;
clrscr ( );
printf ("/nInput a string: /n");
gets (str);
printf ("/nInput a charactor: /n" ;
scanf ("%c", &ch);
n=fun (str, ch);
printf("/nnumber of %c:%d", ch, n);
[填空题]请补充函数proc( ),该函数的功能是:删除字符数组中小于指定字符的字符,指定字符从键盘输入,结果仍保存在原数组中。
例如,输入“abcdefghij”,指定字符为“f”,则结果输出“fghij”。
注意:部分源程序已给出。
请勿改动主函数main和其他甬数中的任何内容。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define M 80
void proc(char str[], char ch)
int i=0, j=0;
while(str[i])
if(str[i]<ch)
(1) ;
else
(2) ;
i++;
(3) ;
void main( )
char str[N], ch;
system("CLS");
printf("/n Input a string: /n");
gets(str);
printf("/n***original string***/n");
puts(str);
printf("n Input a charactor:/n");
scanf("%c", &ch);
proc(str, oh);
printf("/n***new string***/n");
puts(str);
[填空题]请补充函数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)
【1】 ;
else
【2】
i++;
【3】
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);
[填空题]请补充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);
}
[填空题]从键盘输入一组小写字母,保存在字符数组str中。请补充函数fun( ),该函数的功能是:把字符数组str中字符下标为奇数的小写字母转换成对应的大写字母,结果仍保存在原数组中。
例如,输入“acegikm”,输出“aCeGiKm”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#define N 80
void fun (char s[])
int i=0;
while ( 【1】 )
if (i%2!=0)
s[i]-= 【2】 ;
【3】 ;
main ( )
char str [N];
clrscr ( );
printf("/n Input a string:/n");
gets (str);
printf("/n*** original string ***/n");
puts (str);
fun (str);
printf ("In*** new string ***/n");
puts (str);
[填空题]从键盘输入一组小写字母,并保存在字符数组str中。请补充函数fun( ),该函数的功能是:把字符数组str中ASCII码为奇数的小写字母转换成对应的大写字母,结果仍保存在原数组中。
例如,输入“abcdefg”,输出“AbCdEfG”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define N 80
void fun(char s[])
{
int i;
for( 【1】 ; 【2】 ;i++)
{
if( 【3】 )
s[i]-=32;
}
}
main( )
{
char str[N];
clrscr( );
printf("/n lnput a string:/n");
gets(str);
printf("/n*** original string ***/n");
puts (str);
fun (str);
printf("/n*** new string ***/n");
puts (str);
}
[填空题]请补充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);