|
发表于 2017-7-26 21:18:45
|
显示全部楼层
0. 100
1. 10
2. a,b,c
3. a = 14,b = 5, c = 9
4. (x>0)?(z=x):(z=-x)
5.A.
- if(size > 12){
- cost *= 1.05;
- flag = 2;
- }
- bill = cost * flag;
复制代码
B.
- if(ibex > 14){
- sheds = 3;
- }else{
- sheds = 2;
- }
- help = 2 * sheds;
复制代码
C.
- scanf("%d",&score);
- for(;score >= 0;count++){
- scanf("%d",&score);
- }
- printf("count = %d\n",count);
复制代码
0.- #include <stdio.h>
- int main()
- {
- double xiaojiayu = 10000,heiye = 10000;
- int count = 0;
-
- do{
- xiaojiayu = xiaojiayu + 10000 * 0.1;
- heiye = heiye + heiye * 0.05;
- count++;
- }while(heiye < xiaojiayu);
-
- printf("%d年后,黑夜的投资额超过小甲鱼!\n",count);
- printf("小甲鱼的投资额是: %.2lf\n",xiaojiayu);
- printf("黑夜的投资额是: %.2lf\n",heiye);
-
- return 0;
- }
复制代码
1.- #include <stdio.h>
- #define LL 0.08
- int main()
- {
- double ck = 400,lx;
- int count = 0;
-
- do{
- ck -= 50;
- ck += ck * LL;
- if(ck <= 0){
- ck = 0;
- }
- count++;
- }while(ck != 0);
-
- printf("%d年之后,小甲鱼败光了所有家产,再次回到一贫如洗......\n",count);
-
- return 0;
- }
复制代码
2.- #include <stdio.h>
- #include <math.h>
- int main()
- {
- double pi = 0,i = 1;
- _Bool flag = 0;
-
- while(fabs(1/i) >= 1.0e-8){
- if(flag){
- pi += 1 / i * -1;
- }else{
- pi += 1 / i * 1;
- }
- flag = !flag;
- i += 2;
- }
- pi *= 4;
- printf("pi = %.7lf\n",pi);
-
- return 0;
- }
复制代码
3.- #include <stdio.h>
- int main()
- {
- int month,comp,half_comp,young,i,sum; //i是中间变量
-
- month = 1; //月份
- comp = 0; //成熟
- half_comp = 0;//半成熟
- young = 1; //年幼
-
- while(month <= 24){
- i = comp;
- comp += half_comp;
- half_comp = young;
- young = i;
- month++;
- }
-
- sum = comp + half_comp + young;
- printf("两年后可以繁殖%d对兔子!\n",sum);
-
- return 0;
- }
复制代码 |
|