目录
简单完成一个作业,后面会发详细的解析 |
一、💥
下面代码执行的结果是:( )
A.1 2 3 4 5 6 7 8 9 10
B.5 5 5 5 5 5 5 5 5 5
C.死循环的打印5
D.0 1 2 3 4 5 6 7 8 9
#include <stdio.h>
int main()
{
int i = 0;
for (i = 0; i<10; i++)
{
if (i = 5)
printf("%d ", i);
}
return 0;
}
二、💥
关于if语句说法正确是:( )
A.if语句后面只能跟一条语句
B.if语句中0表示假,1表示真
C.if语句是一种分支语句,可以实现单分支,也可以实现多分支
D.else语句总是和它的对齐的if语句匹配
三、💥
关于switch说法不正确的是:( )
A.switct语句中的default子句可以放在任意位置
B.switch语句中case后的表达式只能是整形常量表达式
C.switch语句中case子句必须在default子句之前
D.switch语句中case表达式不要求顺序
四、💥
int func(int a)
{
int b;
switch (a)
{
case 1: b = 30;
case 2: b = 20;
case 3: b = 16;
default: b = 0;
}
return b;
}
则func(1) = ( )
A.30
B.20
C.16
D.0
五、💥
switch( c )语句中,c不可以是什么类型( )
A.int
B.long
C.char
D.float
六、💥
下面代码的执行结果是什么( )
A.secondthird
B.hello
C.firstsecond
D.hellothird
#include <stdio.h>
int main() {
int x = 3;
int y = 3;
switch (x % 2) {
case 1:
switch (y)
{
case 0:
printf("first");
case 1:
printf("second");
break;
default: printf("hello");
}
case 2:
printf("third");
}
return 0;
}
七、💥
从大到小输出
写代码将三个整数数按从大到小输出。
例如:
输入:2 3 1
输出:3 2 1
八、💥
打印3的倍数的数
写一个代码打印1-100之间所有3的倍数的数字
九、💥
最大公约数
给定两个数,求这两个数的最大公约数
例如:
输入:20 40
输出:20
十、💥
打印闰年
打印1000年到2000年之间的闰年
十一、💥
打印素数
写一个代码:打印100~200之间的素数
(转自比特就业课)