更多"请补充main函数。该函数的功能是:求1~100(不包括100)以内所"的相关试题:
[填空题]请补充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函数,该函数的功能是:打印出1~1000中满足:个位数字的立方等于其本身所有数。
本题的结果为;1 64 125 216 729
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数main的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio .h>
main ( )
{
int i,g;
clrscr ( );
for (i=1; i<1000; i++)
{
g= 【1】 ;
if( 【2】 )
printf ("%4d", i);
}
}
[简答题]填空题
请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在b[10]中。
例如:当str1=“ab123456789cde090”时,结果为:
0:2 1:1 2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:2 other charactor:5
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
main( )
{
int i,b[11];
char *str="ab123456789cde090";
char *p=str;
clrscr( );
printf("*** the origial data ***/n");
puts(str);
for(i=0;i<11;i++)
b[i]=0;
while(*p)
{
switch(【1】)
{
case ’’0’’:b[0]++;break;
case ’’1’’:b[1]++;break;
case ’’2’’:b[2]++;break;
case ’’3’’:b[3]++;break;
case ’’4’’:b[4]++;break;
case ’’5’’:b[5]++;break;
case ’’6’’:b[6]++;break;
case ’’7’’:b[7]++;break;
case ’’8’’:b[8]++;break;
case ’’9’’:b[9]++;break;
【2】
}
【3】
}
printf("****** the result ********/n");
for(i=0;i<10;i++)
printf("/n%d:%d",i,b[i]);
printf("/nother charactor:%d",b[i]);
}
[填空题]请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]“123 abcdef ABCDEF!”,结果输出:
“123ABCDEFABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#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函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在N[10]中。
例如:当str1=“ab123456789cde090”时,结果为:
0: 2 1: 1 2: 1 3: 1 4: 1 5: 1 6: 1 7: 1 8: 1 9:2 other charactor:5
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#include <conio.h>
main( )
int i,b[11];
char *str="abl23456789cde090";
char *p=str;
clrscr( );
printf("***the origial data ***/n");
puts(str);
for(i=0;i<11;i++)
b[i]=0;
while(*p)
switch( 【1】 )
case ’0’:b[0]++;break;
case ’1’:b[1]++;break;
case ’2’:b[2]++;break;
case ’3’:b[3]++;break;
case ’4’:b[4]++;break;
case ’5’:b[5]++;break;
case ’6’:b[6]++;break;
case ’7’:b[7]++;break;
case ’8’:b[8]++;break;
case ’9’:b[9]++;break;
[填空题]请补充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函数,该函数的功能是:打印出1~1000中满足:个位数字的立方等于其本身所有数。
本题的结果为;1 64 125 216 729
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数main的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio .h>
main ( )
int i,g;
clrscr ( );
for (i=1; i<1000; i++)
g= 【1】 ;
if( 【2】 )
printf ("%4d", i);
[填空题]请补充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 函数,该函数的功能是:计算两个自然数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);
[填空题]请补充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));
}