|
发表于 2021-10-12 21:09:27
|
显示全部楼层
0.10
1.0
2.a,b,c
3.a=14,b=5,c=9
4.z=x<0?-x:x;
5.A.
- if (size > 12)
- {
- cost = cost * 1.05;
- flag = 2;
- }
- bill = cost * flag;
复制代码
B.
- if (ibex > 14)
- {
- sheds = 3;
- }
- else
- {
- sheds = 2;
- }
- help = 2 * sheds;
复制代码
C.
- while(1)
- {
- scanf("%d", &score);
- if (score < 0)
- {
- break;
- }
- count++;
- }
- printf("count = %d\n", count);
复制代码
0.
- #include <stdio.h>
- void main()
- {
- double fish=10000,fish1=0,darknight=10000;
- int year=0;
- while(1)
- {
- if(darknight>fish+fish1)
- {
- break;
- }
- fish1+=fish*.1;
- darknight+=darknight*.05;
- year++;
- }
- fish+=fish1;
- printf("%d年后,黑夜的投资额超过小甲鱼!\n",year);
- printf("小甲鱼的投资额是:%.2lf\n",fish);
- printf("黑夜的投资额是:%.2lf\n",darknight);
- return;
- }
复制代码
1.
- #include<stdio.h>
- void main()
- {
- float money;
- int year=0;
- for(money=4000000;money>0;year++)
- {
- money-=500000;
- money+=money*.08;
- }
- printf("%d年后,小甲鱼败光了所有的家产,再次回到一贫如洗……\n",year);
- }
复制代码
2.
- #include<stdio.h>
- #include<math.h>
- void main()
- {
- double pi=0,current,stop;
- int n;
- stop=pow(10,-8);
- for(n=0;;n++)
- {
- current=1/(double)(n*2+1);
- if(current<stop)
- {
- break;
- }
- if(n%2)
- {
- current=-current;
- }
- pi+=current;
- }
- printf("%.7lf\n",pi*4);
- }
复制代码
3.
- #include<stdio.h>
- void main()
- {
- int time;
- long long int adult,teen=0,child=0;
- long long int adult1,teen1,child1;
- adult=2;
- for(time=0;time<24;time++)
- {
- child1=child+adult;
- teen1=child;
- adult1=teen;
- child=child1;
- teen=teen1;
- adult=adult1;
- }
- printf("total:%ld\n",adult+teen+child);
- return;
- }
复制代码 |
|