更多"请补充main函数,该函数的功能是:从键盘输入一组整数,使用条件表达式"的相关试题:
[填空题]请补充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函数,该函数的功能是:从键盘输入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函数,该函数的功能是:从键盘输入只有两个整数参与运算的一个四则运算式,然后计算出它的值。注意数字全部为正整数。
例如,输入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
#include
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函数,该函数的功能是:从键盘输入一组字符串,以‘*’结束输入,并显示出这个字符串。
例如,输入abcdefghi*,结果显示adcdefghi。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio. h>
#define N 80
main ( )
{
iht i=-l, j=0;
char str IN];
clrscr ( );
printf("/n Input a string /n");
do
{
i++;
scanf(【1】);
}while(【2】);
printf ("/n**display the string** /n");
while (j<i)
{
printf (【3】);
j++;
}
}
[填空题]请补充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函数,该函数的功能是:从键盘输入若干字符放到一个字符数组中,当桉回车键时结束输入,最后输出这个字符数组中的所有字符。
注意:部分源程序给出如下。
请勿改动主函数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函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的所有字符全部删除。结果仍然保存在原串中。
例如,输入“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函数,该函数的功能是:从键盘输入学生的成绩(用回车键作为分隔符),并统计各分数段学生的人数。具体要求为:A类为90~100分,B类为80~89分,C类为70~79分,D类为60~69分,59分以下的为E类。当成绩为0时结束成绩的输入,并且最后输入的0不进行统计。
例如,输入89,99,45,64,56,78,88,74,66,55,0。结果为
A:1 B:2 C://2 D://2 E://3
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 100
main( )
float score[N];
int bb[5];
int grade, i=-1,n=0;
char ch=’A’;
clrscr( );
printf("Input a score(0~100);/n");
do
i++;
n++;
printf("score[%d]=",i);
scanf ( 【1】 );
while (score[i]!=0);
for(i=0;i<5;i++)
【2】 ;
for(i=0;i<n-1;i++)
grade= 【3】 ;
switch(grade)
case 10:
case 9:bb[0]++;break;
case 8:bb[1]++;break;
case 7:bb[2]++;break;
case 6:bb[3]++; break;
default:bb[4]++;
[填空题]请补充main函数,该函数的功能是:从键盘输入两上字符串并分别保存在字符数组str1和str2中,用字符串str2替换字符串str1前面的所有字符,注意,str2的K度不大于str1,否则需要重新输入。
例如,如果输入strl;=“abced”,str2=“fk”,则输出“fkced”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仪在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<string. h>
main ( )
char strl [ 81], str2 [ 81 ];
char *pl=strl, *p2=str2;
clrscr ( );
do
printf(" Input strl tn");
gets (strl);
printf(" Input str2 In");
gets (str2);
while(【1】);
while(【2】)
*p1++=*p2++;
printf(" Display strl /n");
puts (【3】)
[填空题]请补充main函数,该函数的功能是求方程ax2+bx+c=0的根(方程的系数a,b,c从键盘输入)。
例如, 当a=1,b=2,c=1时, 方程的两个根分别是:
x1=-1.00,x2=-1.00。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#include <conio.h>
#include <math.h>
main( )
float a,b,c,disc,x1,x2,p,q;
scanf("%f,%f,%f",&a,&b,&c);
disc=b*b-4*a*c;
clrscr( );
printf("****** the result ****+*+/n");
if(disc>=0)
x1= 【1】 ;
x2=(-b-sqrt(disc))/(2*a);
printf("x1=%6.2f,x2=%6.2f/n",x1,x2);
else
p= 【2】 ;
q= 【3】 ;
printf("x1=%6.2f+%6.2f i/n",p,q);
printf("x2=%6.2f-%6.2f i/n",p,q);
[填空题]请补充main函数,该函数的功能是:输出方程组“A+B=56,A+2B=72”的一组正整数解。本题的结果是: A=40,B=16。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio. h>
main( )
{
int i, j;
clrscr ( );
for(i=0;i<100; i++)
for (j=0; j<100; j++)
if( 【1】 )
printf ("A=%2d,B=%2d", 【2】 );
}
[填空题]数组xx[N]保存着一组4位无符号整数,其元素的个数通过变量num传入函数fun( )。请补充函数fun( ),该函数的功能是:从数组xx中找出个位和百位的数字相等的所有无符号整数,结果保存在数组yy中,其个数由函数fun( )返回。
例如:当xx[8]={1111,2413,2321,2222,4245,3333,1414, 5335}时,bb[6]={1111,2321,2222,4245,3333,1414)。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio. h>
#include<conio. h>
#define N 1000
int fun (int xx [], int bb [], int num)
{
int i, n=0;
int g,b;
for (i=0; i<num; i++)
{
g= 【1】 ;
b=xx [i]/100%10;
if (g==b)
【2】
}
return 【3】 ;
}
main( )
{
int xx [8] ={1111,2413, 2321, 2222, 4245,
3333,1414,5335 };
int yy[N];
int num=0, n=0, i=0;
num=8;
clrscr ( );
printf ("*****original data ******/n ");
for (i=0; i<num; i++)
printf ("%u ",xx[i]);
printf ("/n/n/n");
n=fun (xx, yy, num);
printf ("/n yy= ");
for (i=0; i<n; i++)
printf ("%u ", yy [i]);
}