|
发表于 2021-9-3 15:53:27
|
显示全部楼层
测试题:
0.
10
1.
0
2.
I value 是啥
3.
a = 14 , b = 5 , c = 9
4.
z = x >= 0 ? x : -x;
5.
if (size > 12){
cost *= 1.05;
flag = 2;
}
bill = cost * flag;
if (ibex > 14){
sheds = 2;
}else{
sheds = 3;
}
help = 2 * sheds;
while(1){
scanf("%d",&score);
if (score < 0){
break;
}
count++;
}
printf("count = %d\n",count);
动动手
# include <stdio.h>
# include <math.h>
int main(){
//动动手0
float principal = 10000, interest1_year = 0, interest1_total = 0, interest2_year = 0, interest2_total = 0 , rate1 = 0.1 , rate2 = 0.05;
int years = 0;
while (interest1_total >= interest2_total){//利用循环计算两人总利润,超过时退出循环
interest1_year = principal * rate1;
interest2_year = (principal + interest2_total) * rate2;
interest1_total += interest1_year;
interest2_total += interest2_year;
years++;
}
printf("%d年后,黑夜的投资额超过小甲鱼。\n",years);
printf("小甲鱼的投资额是:%.2f。\n黑夜的投资额是:%.2f。\n",principal + interest1_total,principal + interest2_total);
printf("\n");
//动动手1
float deposit = 400 , expense = 50, rate = 0.08;
int years_t2 = 0;
while (deposit > 0){
deposit -= 50;
deposit += deposit * rate;
years_t2++;
}
printf("%d年之后,小甲鱼败光了所有家产,再次回到一贫如洗......\n",years_t2);
printf("\n");
//动动手2
int i = 1 , j = -1;
double pi_4 , num;
while (fabs(num = 1.0 / i) > pow(10,-8)){
pi_4 += num;
i = j * (abs(i) + 2);
j = -j;
}
printf("π≈%.7f\n",pi_4 * 4);
printf("\n");
//动动手3
unsigned long long rabbits = 2;
return 0;
}
|
|