更多"请补充main函数,该函数的功能是:计算每个学生成绩的平均分,并把结果"的相关试题:
[填空题]请补充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 函数,该函数的功能是:计算两个自然数n和m(m<10000)之间所有数的和(n和m从键盘输入)。
例如:当n=1,m=100时,sum=5050:当n=100,m=1000时,sum=495550。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main 函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
main ( )
int n, m;
long sum;
【1】
clrscr ( );
printf ("/nInput n,m/n");
scanf ("%d, %d", &n, &m);
while (n<=m)
【2】
n++;
printf ("sum=% 【3】 /n", sum);
[填空题]请补充main函数,该函数的功能是:把1~100间的所有素数保存在数组aa中,然后输出这些素数并计算它们的和。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
main( )
int n, i, j, k, flag, sum;
int aa [50];
sum=O;
k=O;
clrscr ( );
for (i=2; i<100; i++)
【1】;
for (j=2; j<i&&flag; j++)
if (i%j==O)
【2】;
if (flag)
sum+=i;
【3】;
printf("/n*** prime number ***/n");
for (i=0; i<k; i++)
if (i%10==0)
printf ("/n");
printf ("%4d", aa [i]);
printf ("/nsum=%d", sum);
[填空题]请补充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
[填空题]请补充fun( )函数,fun函数的功能是求m的阶乘。
请勿改动main( )函数与其他函数中的任何内容,仅在fun( )函数的横线上填写所需的若干表达式语句。
注意:部分源程序给出如下。
试题程序:
#include<stdio.h>
long fun(int m)
{
if(______)
return(m*fun(______));
return ______;
}
void main( )
{
printf("8!=%ld/n",fun(8));
}
[填空题]请补充fun( )函数,该函数的功能是求m的阶乘。不要改动主函数main( )与他函数中的任何内容,仅在fun( )函数的横线上填写所需的若干表达式或语句。
注意:部分源程序如下。
#include<stdio.h>
long fun(int m)
if (1)
return(m*fun (2) );
return (3) ;
main( )
printf("8!=%ld/n",fun(8));
[简答题]请编写函数proc( ),该函数的功能是:计算n门课程的平均分,计算结果作为函数值返回。
例如,有6门课程的成绩是90.5,72,80,61.5,55,60,则函数的值为69.83。
注意:部分源程序给出如下。
请勿改动main( )函数和其他函数中的任何内容,仅在函数proc( )的花括号中填入所编写的若干语句。
试题程序:
#include<stdio.h>
float proc(float*a,int n)
{
}
void main( )
{
float score[30]={90.5,72,80,61.5,55,60},
aver;
aver=proc(score,6);
printf("/nAverage score is:%5.2f/n",aver);
}
[填空题]请补充main 函数,该函数的功能是:求n!
例如7!=5040。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在 main 函数的横线上填入所编写的若干表达式或语句。
试题程序:
# include<stdio. h>
#include<conio. h>
main( )
{
int i,n;
long f=1;
clrscr ( );
printf("Input n: ");
scanf ("%d", 【1】 );
for( 【2】 ;i<=n; i++)
【3】 ;
printf ("%d!=%1d/n", n, f);
}
[填空题]请补充main函数,该函数的功能是:输出一个NXN矩阵,要求非周边元素赋值0,周边元素赋值1。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio .h>
#define N 10
main( )
{
int bb[N] IN];
iht i,j,n;
clrscr 0;
printf (" /nInput n: /n");
scanf ("%d", &n);
for (i=0; i<n; i++ )
for (j=0; j<n; j++)
{
if(【1】)
bb[i] [j]=l;
else
【2】;
}
printf(" /n*** the result *** /n");
for (i=0; i<n; i++)
{
printf (" /n/n");
for (j=0; j<n; j++)
printf ("%4d",bb [i] [j ] );
}
}
[填空题]请补充main函数。该函数的功能是:求1~100(不包括100)以内所有素数的平均值。
程序运行后的结果为42.40。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
main( )
{
int i, j, n=0,flag;
float aver=0;
clrscr( );
for(j=2;j<100;i++)
{
flag=1;
for(i=2;i<j;i++)
if( 【1】 )
{
flag=0;
break;
}
if( 【2】 )
{
n++;
aver+=j;
}
}
printf("/n/n average=%4.2f", 【3】 );
}
[简答题]填空题
请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]=“123 abcdef ABCDEF!”,结果输出:“123 ABCDEF ABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#include
#define N 80
void main( )
{
int j;
char str[N]=" 123abcdef ABCDEF!";
char *pf=str;
clrscr( );
printf("***original string ***/n");
puts(str);
【1】;
while(*(pf+j))
{
if(*(pf+j)>=’’a’’&&*(pf+j)<=’’z’’)
{
*(pf+j)=【2】;
j++;
}
else
【3】;
}
printf("******new string******/n");
puts(str);
system("pause");
}
[填空题]请补充main函数,该函数的功能是:输出一个NXN矩阵,要求非周边元素赋值0,周边元素赋值1。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio .h>
#define N 10
main( )
int bb[N] IN];
iht i,j,n;
clrscr 0;
printf (" /nInput n: /n");
scanf ("%d", &n);
for (i=0; i<n; i++ )
for (j=0; j<n; j++)
if(【1】)
bb[i] [j]=l;
else
【2】;
printf(" /n*** the result *** /n");
for (i=0; i<n; i++)
printf (" /n/n");
for (j=0; j<n; j++)
printf ("%4d",bb [i] [j ] );
[简答题]请编写函数fun( ),该函数的功能是:计算n门课程的平均分,计算结果作为函数值返回。
例如x有5门课程的成绩是90.5,72,80,61.5,55,则函数的值为71.80。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
float fun (float *a, int n)
{
}
main ( )
{
float score[30]=(90.5,72,80,61.5,55},
aver;
aver=fun(score, 5);
printf("/nAverage score is: %5.2f
/n",aver);
}
[填空题]请补充main函数,该函数的功能是:输出一个3×3的矩阵,要求必须使用行指针表示输出变量。
注意;部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<s tdio. h>
main( )
static int array[3] [3]=9,8,7, 6,5,
4, (3,2,1;
iht (*p) [3],j,i;
p=【1】
clrscr ( );
for (i=0; i<3; i++)
printf (" /n/n" );
for (j=0; j<3; j++)
printf("%4d", 【2】 );