|
发表于 2022-6-3 11:21:15
|
显示全部楼层
测试题:
0.100个
1.9个
2.a,b,c
3.a=3,b=4,c=10
4.x = x>=0?x:-x;
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:
If(score < 0)
{
printf(“count = %d\n”,count);
}
count++;
scanf(“%d”,&score);
动动手
0.
#include <stdio.h>
int main()
{
float sum = 10000,profit2=0,sum2=10000,total1,total2;
int n=1
;
while(total2 <= total1)
{
total1 = sum + sum * 0.1 * n;
profit2 = sum2 * 0.05;
total2 = sum2 +profit2;
sum2 += profit2;
n++;
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n",n-1);
printf("小甲鱼的投资额是:%.2f\n",total1);
printf("黑夜的投资额是:%.2f\n",total2);
return 0;
}
1.
#include <stdio.h>
int main()
{
float money = 4000000,profit,cost = 500000;
int n=1;
while(money>0)
{
profit = money * 0.08;
money = money + profit - cost;
n++;
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗......\n",n);
return 0;
}
2.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int n;
float number,sum=1;
for(n=1;fabs(pow(-1,n+1)*(1/(2*(n+1)+1))) < pow(10,-8);n++)
{
number = pow(-1,n)*(1/(2*n+1));
sum += number;
}
printf("%.7f\n",sum);
return 0;
}
3. |
|