|
发表于 2021-6-11 14:54:06
|
显示全部楼层
0:10个
1:11个
2:a,b,c
3:a=14,b =5,c =9
4:z=x>0?x:x*(-1)
5:
A;
if (size > 12)
{
cost = cost * 1.05;
flag = 2;
break;
}
bill = cost * flag;
B:
if (ibex > 14)
{
sheds = 3;
break;
}
sheds = 2;
help = 2 * sheds;
C:
while(1)
{
readin: scanf("%d", &score);
if (score < 0)
{
printf("count = %d\n", count);
break;
}
count++;
}
0:
#include<stdio.h>
int main ()
{
float fish = 10000, night_sum = 10000,fish_sum= 10000;
int year;
for (year = 0; night_sum <= fish_sum; year++)
{
fish_sum = fish_sum + fish * 0.1;
night_sum= night_sum + night_sum * 0.05;
}
printf("%d年后,黑夜的投资额将超过小甲鱼!\n", year);
printf("小甲鱼的投资额是:%.2f\n", fish_sum);
printf("黑夜的投资额是:%.2f\n", night_sum);
return 0;
}
1:
#include<stdio.h>
int main()
{
float sum;
int year;
for (sum = 4000000,year = 0; sum > 0; year++)
{
sum -= 500000;
sum += sum * 0.08;
}
printf("%d年之后,小甲鱼败光了所有家产,再次回到一贫如洗……\n", year);
return 0;
}
2:
#include<stdio.h>
#include<math.h>
int main()
{
double num, num_numerator = 1, num_denominator = 1,temp = 0, sum;
int i = 0;
do
{
if (i % 2 == 0)
{
num = num_numerator / num_denominator;
}
else
{
num = -(num_numerator / num_denominator);
}
temp += num;
num_denominator += 2;
i++;
} while (fabs(num) >= 10e-8);
sum = (temp - num) * 4;
printf("PI的小数点后前7位的近似值是:%.7f\n", sum);
return 0;
}
3:
#include<stdio.h>
int main()
{
long month, new_rab, old_rab,temp, sum = 0;
for (month = 2, new_rab = 1, old_rab = 0; month <= 24; month ++)
{
temp = old_rab;
old_rab += new_rab;
new_rab = temp;
}
sum = old_rab + new_rab;
printf("两年后总共有%ld对兔子\n", sum);
return 0;
}
|
|