|
发表于 2021-8-15 22:16:04
|
显示全部楼层
0.10个A
1.10个B
2.a,b,c
3.b=4,c=5,a=30
4.#include<stdio.h>
int main()
{
int z;
int x=m;
if(x>0)
{
z=x;
}
else
{
z=-x;
}
return 0;
}
5.
if (size > 12)
{
goto a;
}
goto b;
a: cost = cost * 1.05;
flag = 2;
b: bill = cost * flag;
可更改为
if (size > 12)
{
cost = cost * 1.05;
flag = 2;
}
else
{
bill = cost * flag;
}
B段代码可更改为
if (ibex > 14)
{
sheds = 3 ;
}
else
{
sheds = 2;
help = 2 * sheds;
}
C段代码可以改为
do{
readin: scanf("%d", &score);
printf("count = %d\n", count);
count++;
}while(score < 0)
动动手答案。
#include <stdio.h>
int main()
{
int i = 0;
float m1,m2;
m2 = 10000;
do
{
i ++;
m1 = 10000 + 1000*i;
m2 = m2*(1+0.05);
}while(m2<=m1);
printf("%d年后,黑夜的投资额超过小甲鱼!\n",i);
printf("小甲鱼的投资额是:%.2f元\n",m1);
printf("黑夜的投资额是:%.2f元\n",m2);
return 0;
}
#include<stdio.h>
int main()
{
int i =0 ;
float total_money =350,temp =400 ;//总共家产 (万元)
while(total_money>0)
{
total_money = temp + total_money*0.08 -50;
temp = total_money;
printf("目前资产:%.2f万元\n",total_money);
if(total_money>0)
{
i++;
printf("第%d年资产:%.2f万元\n",i,total_money);
}
if(total_money<=0)
{
printf("经过了%d年,小甲鱼败光了家产!\n",i);
printf("小甲鱼欠债%.2f万元!",total_money);
break;
}
}
return 0;
}
2.
#include<stdio.h>
#include<math.h>
int main()
{
float PI=0,j=1.0,k=1.0;
while(1/k>=1e-4)
{
PI=PI+j*1.0/k ;
j -= 1*j;
k = k+2;
}
PI = 4 * PI;
printf("圆周率是:%f\n!",PI);
return 0;
}
3. |
|