第1题
从键盘任意输入一个3位整数,编程计算并输出它的逆序数(忽略整数前的正负号)。例如,输入-123,则忽略负号,由123分离出其百位1、十位2、个位3,然后计算3*100+2*10+1 = 321,并输出321。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。#include <math.h> #include <stdio.h> int main() { int x, b0, b1, b2, y; printf("Input x:"); scanf("%d", &x); x = (int)fabs(x); b2 = ________; /* 计算百位数字 */ b1 = _________; /* 计算十位数字 */ b0 = _________; /* 计算个位数字 */ y = b2 + b1*10 + b0*100; printf("y = %d\n",y); return 0; }
A、第10行: x / 100 第12行: (x - b2 * 100) / 10 第14行: x % 10
B、第10行: x % 100 第12行: (x - b2 * 100) / 10 第14行: x / 10
C、第10行: x / 100 第12行: (x - b2 * 100) % 10 第14行: x / 10
D、第10行: x / 10 第12行: (x - b2 * 10) / 10 第14行: x % 100
第2题
为实现指定功能,程序【】处应填写的语句是( )。
A.k—k+1
B.X=X一1
C.X—X/k
D.k—k一1
第3题
请编码实现动物世界的继承关系,要求:
(1)父类动物类(Animal)具有属性:name;行为:吃饭(eat)、睡觉(sleep)
(2)子类为兔子类(Rabbit)
(3)不同的动物吃的行为各不相同(兔子吃草);但睡觉的行为是一致的。
(4)通过继承实现以上需求,并编写测试类AnimalTest进行测试。
第4题
例如,输入: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)
【 】;
else
【 】;
if(max<c)
【 】;
printf("max=%d\n",max);
}
第5题
从键盘任意输入10个整数,计算并输出最大值和最小值及其它们在数组中的下标位置。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 程序运行结果示例1: Input 10 numbers:1 2 3 4 5 6 7 8 9 10↙ max=10,pos=9 min=1,pos=0 程序运行结果示例2: Input 10 numbers:2 4 5 6 8 10 1 3 5 7 9↙ max=10,pos=5 min=1,pos=6 #include <stdio.h> int FindMax(int a[], int n, int *pMaxPos); int FindMin(int a[], int n, int *pMinPos); int main() { int a[10], maxValue, maxPos, minValue, minPos, i; printf("Input 10 numbers:"); for (i=0; i<10; i++) { scanf("%d", &a[i]); 输入10个数 } maxvalue="FindMax(a," 10, _________); 找最大值及其所在下标位置 minvalue="FindMin(a," 找最小值及其所在下标位置 printf("max="%d,pos=%d\n"," maxvalue, maxpos); printf("min="%d,pos=%d\n"," minvalue, minpos); return 0; 函数功能:求有n个元素的整型数组a中的最大值及其所在下标位置,函数返回最大值 int findmax(int a[], n, *pmaxpos) i, max; max="a[0];" 假设a[0]为最大值 __________; 假设最大值在数组中的下标位置为0 for (i="1;" i if (a[i]> max) { max = a[i]; __________; //pMaxPos指向最大值数组元素的下标位置 } } return max ; } //函数功能:求有n个元素的整型数组a中的最小值及其所在下标位置,函数返回最小值 int FindMin(int a[], int n, int *pMinPos) { int i, min; min = a[0]; //假设a[0]为最小 __________; //假设最小值在数组中的下标位置为0 for (i=1; i<10; i++) { if (a[i] min) min="a[i];" __________; pminpos指向最小值数组元素的下标位置 } return ;> A、第13行:&maxPos 第14行:&minPos 第25行:*pMaxPos = 0 第32行:*pMaxPos = i 第43行:*pMinPos = 0 第50行:*pMinPos = i
B、第13行:maxPos 第14行:minPos 第25行:pMaxPos = 0 第32行:*pMaxPos = i 第43行:pMinPos = 0 第50行:*pMinPos = i
C、第13行:maxPos 第14行:minPos 第25行:pMaxPos = 0 第32行:pMaxPos = i 第43行:pMinPos = 0 第50行:pMinPos = i
D、第13行:&maxPos 第14行:&minPos 第25行:pMaxPos = 0 第32行:pMaxPos = i 第43行:*pMinPos = 0 第50行:*pMinPos = i
第6题
第7题
注章:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序;
include<stdio.h>
include<conio.h>
include<stdlib.h>
define N 20
double fun(int a[ ][N],int n)
{
int i,j;
int k;
double s=0.0;
double aver=0.0;
printf("*****The array*****\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=rand()%10;
printf("%4d",a[i][j]);
if(【 】)
s+=a[i][j];
}
printf("\n");
}
k=【 】;
aver=【 】;
return aver;
}
main( )
{
int a[N][N];
int n;
double S;
Clrscr( );
printf("*****Input the dimension Of array N*****\n");
scanf(“%d”,&n);
S=fun(a,n);
printf(“***** THE RESULT *****\n”);
printf(“The average is %2,3f\n”,S);
}
第9题
Private Sub Command1_Click()
Dim x As Integer
x=InputBox( “ 请输入一个正整数 ” )
While x>_ _[11] ___
Print x Mod 10;
x=x\10
Wend
Print__ [12] __
End Sub
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!