|
发表于 2019-4-10 17:24:20
|
显示全部楼层
0. 请问下边代码将打印多少个 'A'?l{XbOt2r
RA39"X6IE}v_H`:SuNr%#=^fCw.0
1. #include <stdio.h>
2.
3. int main()
4. {
5. int i, j;
6.
7. for (i = 0; i != 10, j != 10; i++)
8. {
9. for (j = 0; j < 10; j++)
10. {
11. putchar('A');
12. }
13. }
14.
15. putchar('\n');
16.
17. return 0;
18. }
答:10个
1. 请问下边代码会打印多少个 'B'?0L:?F
]d|ojcH'5iq^2}W=K>7<B8y;wDfkPn
1. #include <stdio.h>
2.
3. int main()
4. {
5. int i = 0;
6.
7. while (i++)
8. {
9. if (i > 10)
10. {
11. goto Label;
12. }
13. putchar('B');
14. }
15.
16. Label: putchar('\n');
17.
18. return 0;
19. }
答:九个。
2. 请写出表达式 a = b = c = 5 中的"l-value"?
答:5
3. 请问表达式 a = (b = 3, 4, c = b++ + 5, ++c + ++b); 执行后,整型变量 a、b、c 的值是?
答:
A=13
B=5
C=9
4. 请使用条件运算符求出变量 x 的绝对值,并存放到变量 z 中。
答:
X>0?x:-x;
5. C 语言其实在大部分情况下不使用 goto 语句也能做得很好,请尝试将下列代码段写成不带 goto 语句的版本。u6BwLkd
"6Oo|nq>a=He1w~+B%@ 'pc&5C
A. 版权属于:bbs.fishc.com
1. if (size > 12)
2. {
3. goto a;
4. }
5. goto b;
6. a: cost = cost * 1.05;
7. flag = 2;
8. b: bill = cost * flag;
复制代码
If(size>12)
{
cost=cost*1.05;
}
Else
{
bill = cost*flag;
}
B. 版权属于:bbs.fishc.com
1. if (ibex > 14)
2. {
3. goto a;
4. }
5. sheds = 2;
6. goto b;
7. a: sheds = 3;
8. b: help = 2 * sheds;
复制代码
If(ibex>14)
{
sheds=3;
}
Else
{
Sheds-2;
Help=2*sheds;
}
C.版权属于:bbs.fishc.com
1. readin: scanf("%d", &score);
2. if (score < 0)
3. {
4. goto stage2;
5. }
6. count++;
7. goto readin;
8. stage2: printf("count = %d\n", count);
for(score=scanf(“%d”,&score);score>=0;count++)
{
score = scanf(“%d”,&score);
}
Printf(“count = %d\n”,count);
#include <stdio.h>
main()
{
float fish=10000.00,heiye=10000.0;
int year=0;
for (;fish>=heiye;year++)
{
fish += 1000;
heiye *=1.05;
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n",year);
printf("小甲鱼的投资额是:%.2f\n",fish);
printf("黑夜的投资额是:%.2f\n",heiye);
}
#include <stdio.h>
main()
{
int year=0;
float money=400.00;
for (;;year++)
{
money -= 50;
if(money<0)
{
year++;
break;
}
else
{
money *=1.08;
}
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗......\n",year);
}
#include <stdio.h>
main()
{
long int sum,adult=1,child=0,new0=0,new1=0,newj=0;
int time;
for (time=0;time<=24;time++)
{
child=child+adult;
new0 = new1;
new2 = newj;
newj = adult;
adult +=new0;
}
sum = child+adult;
printf("一共有%ld对兔子!\n",sum);
}
~
|
|