第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题
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
第4题
第5题
从键盘任意输入一个整数,编程判断它的奇偶性。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。#include <stdio.h> int main() { int a; printf("Input an integer number:"); scanf("%d", &a); if (________) printf("a is an even number\n"); else printf("a is an odd number\n"); return 0; }
A、a%2 == 0
B、a%2 = 0
C、a/2 = 0
D、a%2 != 0
第8题
例如,输入1,2,3,5,4,0时,最大的数为5。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写出的若干表达式或语句。
试题程序:
include<stdio.h>
include<conio.h>
define N 100
main()
{
int num[N];
int i=-1;
int max=0;
clrscr();
printf("\nInput integer number:\n");
do
{
i++;
printf("num[%d]=",i);
scanf("%d",【 】);
max=【 】num[i]:max;
}while (【 】);
printf("max=%dkn",max);
}
第9题
例如,输入: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);
}
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!