题目内容 (请给出正确答案)
[主观题]

【填空题】在【】位置填上正确的代码。程序功能:输入N个学生的某课程成绩,计算平均成绩。 【填空题】在【】位置填上正确的代码。程序功能:输入N个学生的某课程成绩,计算平均成绩。

【填空题】在【】位置填上正确的代码。程序功能:输入N个学生的某课程成绩,计算平均成绩。【填空题】在【】位置填上正确的代码。程序功能:输入N个学生的某课程成绩,计算平均成绩。
提问人:网友lujuan467 发布时间:2022-01-07
参考答案
  抱歉!暂无答案,正在努力更新中……
如搜索结果不匹配,请 联系老师 获取答案
更多“【填空题】在【】位置填上正确的代码。程序功能:输入N个学生的…”相关的问题
第1题
试题1

本题程序的功能是从键盘上输入若干个学生的成绩,统计并输出最高成绩和最低成绩,当输入负数时结束输入。请将下述程序补充完整。(注意:不改动程序的结构,不得增行或删行。)

main()

{ float x,amax,amin;

scanf(“%f”,&x);

amax=x;

amin=x;

while(【1】)

{ if(x>amax) amax=x;

if(【2】) amin=x;

scanf(“%f”,&x);

}

printf(“\namax=%f\namin=%f\n”,amax,amin) ;

}

点击查看答案
第2题
阅读以下说明和C程序代码,将应填入(n)处的字句写在对应栏内。

【说明】

下面C程序代码的功能是:对于输入的一个正整数n(100≤n<1000),先判断其是否是回文数(正读反读都一样的数)。若不是,则将n与其反序数相加,再判断得到的和数是否为回文数,若还不是,再将该和数与其反序数相加并进行判断,依此类推,直到得到一个回文数为止。例如,278不是回文数,其反序数为872,相加后得到的1150还不是回文数,再将1150与其反序数511相加,得到的1661是回文数。

函数int isPalm(long m)的功能是:将正整数m的各位数字取出存入数组中,然后判断其是否为回文数。若m是回文数则返回1,否则返回0。

【C程序代码】

include <stdio.h>

include <stdlib.h>

int isPalm(long m)

{ /*判断m是否为回文数*/

int i = 0, k = 0;

char str[32];

while (m > 0) { /*从个位数开始逐个取出m的各位数字并存入字符数组str*/

str[k++] =(1)+ '0';

m = m / 10;

}

for(i = 0; i < k/2; i++) /*判断str中的k个数字字符序列是否是回文*/

if (str[i] != str[(2)] ) return 0;

return 1;

}

int main ()

{

long n, a, t;

printf("input a positive integer:"); scanf("%ld",&n);

if (n < 100 || n > =1000) return -1 ;

while((3)) { /*n不是回文数时执行循环*/

printf("%ld-> ", n);

for(a = 0, t = n; t > 0; ) { /*计算n的反序数并存入a*/

a =(4)*10 + t % 10; t = t / 10;

} /*end of for*/

n =(5); /*与反序数求和*/

} /*end of while*/

printf ("%id\n",n);

system("pause"); return 0;

}

点击查看答案
第3题
【程序说明】 程序功能是判断一个自然数是否为质数。

【程序】

SET TALK OFF

INPUT“请输入一个大于1的自然数:” (1)

K=0 &&K值为0表示所输入的数是质数,为1表示不是质数

J=2

DO WHILE J<N

IF MOD(N,J) (2)

(3)

LOOP

ELSE

K=1

EXIT

ENDIF

ENDDO

IF K=0

? (4) +“是质数”

ELSE

? “NO!”

ENDIF

SET TALK ON

RETURN

(1)

A.ON N

B.TO N

C.GO N

D.INTO N

点击查看答案
第4题
阅读程序。阅读下列C++程序,对每条语句进行注释,说明其作用(请粘贴源代码或屏幕截图,不要上传附件)。 #include <iostream> using namespace std; class CTest { private: int x, y; public: CTest(int p1 = 0, int p2 = 0) { x = p1; y = p2; } CTest(CTest &p) { x = p.x; y = p.y; } void Show( ) { cout << x << “, “ << y << endl; } }; int main( ) { CTest obj1; obj1.Show( ); CTest obj2(2, 5); obj2.Show( ); CTest obj3(obj2); obj3.Show( ); return 0; }
点击查看答案
第5题
阅读以下说明及C++程序代码,将应填入(n)处的语句写在对应栏内。

【说明】

本程序的功能是实现任意两个大整数的乘法运算,例如:

输入整数1:8934793850094505800243958034985058

输入整数2:234584950989689084095803583095820923

二者之积:

209596817742739508050978890737675662366433464256830959194834854876 8534

【C++代码】

include<iostream.h>

const int MAXINPUTBIT=100;

const int MAXRESULTBIT=500;

class LargeNumber{

int i,j;

int temp;

int one[MAXINPUTBIT+1];

int onebit; //one的位数

int two[MAXINPUTBIT+1];

int twobit; //two的位数

int result[MAXRESULTBIT+1];

public:

LargeNumber();

~LargeNumber();

int inputone(); //出错返叫0,否则返回1

int inputtwo(); //同上

void multiplication(); //乘

void clearresult(); //清零

void showresult(); //显示

};

LargeNumber∷LargeNumber()

{

for(i=0;i<=MAXINPUTBIT;i++)

{

one[i]=0;

two[i]=0;

}

nebit=0;

twobit=0;

inputone();

inputtwo();

}

LargeNumber∷~LargeNumber()

{

}

int LargeNumber∷inputone()

{

char Number[MAXINPUTBIT+1];

cout<<"Please enter one:";

cin>>Number;

i=0;

j=MAXINPUTBIT;

while(Number[i]!='\0')

i++;

nebit=i;

for(i--;i>=0;i--,j--)

{

if(int(Number[i])>=48&&int(Number[i])<=57)

(1); //由字符转换为数字

else

return 0;

}

return 1;

}

int LargeNumber∷inputtwo()

{

char Number[MAXINPUTBIT+1];

cout<<"Please enter two:";

cin>>Number;

i=0;

j=MAXINPUTBIT;

while(Number[i]!='\0')

i++;

twobit=i;

for(i--;i>=0;i--,j--)

{

if(int(Number[i])>=48&&int(Number[i])<=57)

two[j]=int(Number[i]-48); //由字符转换为数字

else

return 0;

}

return 1;

}

void LargeNumber∷multiplication() //乘法

{

clearresult();

int m;

for(i=MAXINPUTBIT;i>=0;i--)

{

temp=two[i];

for(j=(2),m=MAXINPUTBIT;m>=0;m--,j--)

{

result[j]+=temp*one[m];

if(result[j]>9)

{

result[j-1]+=result[j]/10;

(3);

}

}

&n

点击查看答案
第6题
以下程序的功能是:从键盘上输入若干个学生的成绩,统计计算出平均成绩,并输出低于平均分的学生成绩,用输入负数结束输入。 main() { float x[1000],sum=0,ave,a; int n=0,i; printf("Enter mark:\n");scanf("%f",&a); while(a>=0.0&&n<1000) {sum+【 】;x[n]=【 】; n++;scanf("%f",&a); } ave=【 】; printf("Output:\n"); printf(ave=%f\n",ave); for(i=0;i<n;i++) if(【 】) printf("%t\n",x[i]); }
点击查看答案
第7题
以下程序的功能是从键盘输入若干学生的成绩,并输出最高成绩和最低成绩,当输入负数时结束。请填空。 include <stdio.h> main() { float x,amax,amin; scanf("%f",&x); amax=x; amin=x; while(【 】) { if(x>amax)amax=x; else if(【 】) amin=x; scanf("%f",&x); } printf("\n amax=%f\n amin=%f\n",amax,amin); }
点击查看答案
第8题
阅读以下说明及C++程序代码,将应填入(n)处的语句写在对应栏内。

【说明】

本程序的功能是生成螺旋方阵,用户可以输入该方阵的行列数,然后就生成对应的螺旋方阵。例如:当n=5时,对应的螺旋方阵如下:

1 16 15 14 13

2 17 24 23 12

3 18 25 22 11

4 19 20 21 10

5 6 7 8 9

【C++代码】

include"stdio.h"

include"iostream,h"

int array[11][11];

int temp;

int ROW;

void godown(int &m,int &a)

{

for(temp=1; temp<=ROW;temp++)

if(array[temp][a]==0)

array[temp][a]=(1);

a++;

}

void goright(int &m,int &b)

{

for(temp=1;temp<=ROW;temp++)

if(array[b][temp]==0)

array[b][temp]=m++;

b--;

}

void goup(int &m.int &c)

{

for(temp=ROW;temp>0;temp-)

if(array[temp][c]==0)

array[temp][c]=m++;

c--;

}

void goleft(int &m,int &d)

{

for(temp=ROW;temp>0;temp--)

if(array[d][temp]==0)

array[d][temp]=m++;

(2);

}

void main()

{

int a,b,c,d,max,m;

cin>>ROW;

cout>>end1;

for(a=1;a<=ROW;a++)

for(b=1;b<=ROW;b++)

(3);

m=1;

a=d=1;

b=c=ROW;

max=(4);

whiie(m<=max)

{

godown(m,a);

(5) (m,b);

goup(m,c);

goleft(m,d):

}

for(a=1;a<=ROW;a++)

{

for(b=1;b<=ROW;b++)

printf("%3d ",array[a][b]);

cout<<end1;

}

}

点击查看答案
第9题

下面程序的功能是比较用户键盘输入的口令userInput与内设的口令password是否相同。若相同,则输出"Correct password! Welcome to the system...",若userInput <password,则输出"invalid password!user input> password"。 按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include <stdio.h> #include <string.h> int main() { char password[7] = "secret"; char userInput[81] ; printf("Input Password:"); scanf(_____________); if ( ______________ ) printf("Correct password! Welcome to the system...\n"); else if ( ___________________) printf("Invalid password!user input <password\n"); else printf("invalid password!user input> password\n"); return 0; }

A、第8行: "%s", userInput 第9行: strcmp(userInput, password) == 0 第11行: strcmp(userInput, password) < 0

B、第8行: "%c", userInput 第9行: strcmp(userInput, password) = 0 第11行: strcmp(userInput, password) < 0

C、第8行: "%s", userInput 第9行: userInput==password 第11行: userInput <password>

D、第8行: "%c", userInput 第9行: strcpy(userInput, password) == 0 第11行: strcpy(userInput, password) < 0

点击查看答案
第10题
下面是一个求素数的程序,请填空。#include “math.h” int main(int argc, char *argv[]) { int n,k,i=1; scanf("%d",&n); k=sqrt(n); while( ++i<=k ) {if (( [填空处] {printf("%d is not a prime!\n",n); break ; } if(i>=k+1) printf("%d is a prime!\n",n); }

A、n/i

B、n%i

C、n/k

D、n%k

点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信