|
发表于 2022-12-25 12:48:49
|
显示全部楼层
测试题:
0. 10个
1. 11个
2. c=5;b=c;a=b;
3. a==14,b==5,c==9
4.- #include<stdio.h>
- int main(void)
- {
- double x;
- double z;
- scanf("%lf", &x);
- if(x<0) x=-x;
- z=x;
-
- printf("%.2lf\n", z);
- return 0;
- }
复制代码
5.
A.- if (size > 12)
- {
- cost = cost * 1.05;
- flag = 2;
- }
- bill = cost * flag;
复制代码
B.- if (ibex > 14)
- {
- sheds = 3;
- }
- sheds = 2;
- help = 2 * sheds;
复制代码
C.- while(scanf("%d", &score))
- {
- if(score<0)
- {
- printf("count = %d\n", count);
- break;
- }
- count++;
- }
复制代码
动动手:
0.- #include<stdio.h>
- int main(void)
- {
- double Money_xjy=10000;
- double Money_hy=10000;
- int years=0;
- do
- {
- Money_xjy=Money_xjy + 10000*0.1;
- Money_hy=Money_hy + Money_hy*0.05;
- years++;
- }while(Money_hy<=Money_xjy);
- printf("%d年后,黑夜的投资额超过小甲鱼!\n", years);
- printf("小甲鱼的投资额是:%.2lf\n", Money_xjy);
- printf("黑夜的投资额是:%.2lf\n", Money_hy);
- return 0;
- }
复制代码
1.- #include<stdio.h>
- int main(void)
- {
- double total=400;
- int years=0;
- while(total>0)
- {
- total-=50;
- years++;
- if(total>0) total+=total*0.08;
- }
- printf("%d年之后, 小甲鱼败光了所有的家产,再次回到一贫如洗……\n", years);
- return 0;
- }
复制代码
2.- #include<stdio.h>
- #include<math.h>
- int main(void)
- {
- int x=-1;
- int i=0;
- int fm=1;
- double PI_4=0;
- double num;
- do
- {
- num=1.0/fm;
- fm+=2;
- PI_4+=pow(x, i++)*num;
- } while (num>pow(10, -8));
- printf("%.8lf\n", PI_4*4);
-
- return 0;
- }
复制代码
3.- #include<stdio.h>
- int main(void)
- {
- int a=1;
- int b=1;
- int m=24;
- int i;
- for(i=0; i<m; i++)
- {
- b=a+b;
- a=b-a;
- }
- printf("%d\n", b);
- return 0;
- }
复制代码 |
|