更多"请补充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)
【1】 ;
else
【2】 ;
if(max<c)
【3】 ;
printf("max=%d/n",max);
}
[填空题]请补充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函数,该函数的功能是:从键盘输入一组字符串,以‘*’结束输入,并显示出这个字符串。
例如,输入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函数,该函数的功能是:从键盘输入一个字符串并保存在字符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函数,该函数的功能是:从键盘输入只有两个整数参与运算的一个四则运算式,然后计算出它的值。注意数字全部为正整数。
例如,输入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函数,该函数的功能是:从键盘输入学生的成绩(用回车键作为分隔符),并统计各分数段学生的人数。具体要求为: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函数,该函数的功能是:从键盘输入一个长整数,如果这个数是负数,则取它的绝对值,并显示出来。例如,输入:-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函数,该函数的功能是:从键盘输入两上字符串并分别保存在字符数组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函数,该函数的功能是:从键盘输入一个长整数,如果这个数是负数,则取它的绝对值,并显示出来。
例如,输入:-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函数,该函数的功能是求方程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函数,该函数的功能是:从一个字符串中截取前面若干个给定长度的子字符串。其中,str1指向原字符串,截取后的字符存放在str2所指的字符数组中,n中存放需截取的字符个数。
例如:当str1=“cdefghij”,然后输入4,则str2=“cdef”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#define LEN 80
main( )
{
char str1[LEN],str2[LEN];
int n,i;
clrscr( );
printf("Enter the string:/n");
gets(str1);
printf("Enter the position of the string
deleted:");
scanf(【1】);
for(i=0;i
[填空题]请补充main函数,该函数的功能是:从一个字符串中截取前面若干个给定长度的子字符串。其中,str1指向原字符串,截取后的字符存放在str2所指的字符数组中,n中存放需截取的字符个数。
例如:当str1=“cdefghij”,然后输入4,则str2=“cdef”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define LEN 80
main( )
char str1[LEN],str2[LEN];
int n,i;
clrscr( );
printf("Enter the string:/n");
gets(str1);
printf "Enter the position of the string deleted:");
scanf( 【1】 );
for(i=0;i<n;i++)
【2】
str2[i]=‘/0’;
printf("The new string is:%s/n", 【3】 );
[填空题]请补充fun函数,fun函数的功能是求n的阶乘。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句
试题程序:
#include<stdio.h>
long fun(int n)
if( (1) )
return(n*fun( (2) ));
return (3) ;
main( )
printf("10!=%1d/n",fun(10));