题目详情
当前位置:首页 > 计算机考试 > 计算机等级考试
题目详情:
发布时间:2023-10-04 17:47:45

[填空题]请补充main( )函数,该函数的功能是:把1~100的所有素数保存在数组arr中,然后输出这些素数并计算它们的和。 注意:部分源程序给出如下。 请勿改动main( )函数和其他函数中的任何内容,仅在main( )函数的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdlib.h> #include<stdio.h> void main( ) { int i,j,k,flag,sum; int arr[50]; sum=0; k=0; system("CLS"); for(i=2;i<100;i++) { ______; for(j=2;j<i&&flag;j++) if(i%j==0) { ______; } if(flag) { sum+=i; ______; } } printf("/n***prime nHmber***/n"); for(i=0;i<k;i++) { if(i%10==0) printf("/n"); printf("%4d",arr[i]); } printf("/nsum=%d",sum); }

更多"请补充main( )函数,该函数的功能是:把1~100的所有素数保存在"的相关试题:

[填空题]请补充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函数。该函数的功能是:求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函数。该函数的功能是:求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中取出所有数字字符,并分别计数,然后把结果保存在数组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函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则 str2=“cegi”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#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<j;i+=2)
*p2++=*(str1+i);
*p2=’/0’;
printf("/nThe new string is:%s/n", 【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函数,该函数的功能是:把一维数组中的元素逆置。结果仍然保存在原数组中。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio.h> #define N 10 main ( ) { int i, j, t; int bb[N]; clrscr ( ); for (i=0; i<N; i++) bb[i]=i; printf("/n*** original list ***/n"); for (i=0;i<N; i++) printf ("%4d",bb [i] ); for( 【1】 ; j<=i; 【2】 ) { t=bb [j ]; bb [j ] =bb [i]; bb[i]=t; } printf("/n****** new list ******/n"); for (i=0; i<N; i++) printf ("%4d",bb [i] ); }
[填空题]请补充main函数,该函数的功能是:计算每个学生成绩的平均分,并把结果保存在数组bb中。 例如,当scorer[N][M]={{83.5,82,86,65,67),{80,91.5,84, 99,95){90.5,95,86,95,97}}时,三个学生的平均分为76.7 89.9 92.7。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若千表达式或语句。 试题程序: #include<stdio.h> #define N 3 #define M 5 main( ) { int i,j; static float score[N][M]={{83.5,82,86, 65,67},{80,91.5,84,99,95},{90.5,95, 86,95,97}}; float bb[N]; clrscr( ); for(i=0;i<N;i++) 【1】; for(i=0;i<N;i++) { for (j=0; j<M; j++) 【2】; bb [i]/=M; } for (i=0; i<N; i++) print f (" knstudent %d/t average =%5.1f",i+l,bb[i]); }
[填空题]请补充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函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。 例如:当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函数,该函数的功能是:如果数组aa的前一个元素比后一个元素小,则把它保存在数组比中并输出。
例如,输入“40,51,62,33,35,52,48,95,66, 73”,则结果输出“40,51,33,35,48,66”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio. h>
#define N 10
main ( )

int i, n=0;
int aa [N]=40, 51, 62,33, 35, 52, 48, 95,
66,73;
int bb[N];
clrscr ( );
for (i=0; i< 【1】 ; i++)
if (aa [i] <aa [i+l] )
【2】 ;
printf("/n*** display bb ***In");
for (i=0; i<n; i++)
printf("bb[%d]=%2d ", 【3】 );

[填空题]请补充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函数,该函数的功能是:打印出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~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函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的所有字符全部删除。结果仍然保存在原串中。
例如,输入“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);

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
  • 支付完成
  • 取消支付
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码