|
|
发表于 2025-11-6 19:42:38
|
显示全部楼层
0. 10
1. 9
2. c=5, b=c, a=b
3.14 5 9
4. z= x>=0 ? x : -x
5.
0.
#include <stdio.h>
#include <math.h>
int main()
{
int year;
float a, b;
a = 10000;
b = 10000;
for(year = 0; a >= b; year++)
{
a = a + 10000*0.1;
b = b * 1.05;
}
printf("%i年后,黑夜的投资额超过小甲鱼!\n小甲鱼的投资额为%.2f元\n黑夜的投资额为%.2f元",year, a, b);
return 0;
}
1.
#include <stdio.h>
#include <math.h>
int main()
{
int year;
float a;
a = 400;
for(year = 0; a >= 0; year++)
{
a = (a-50) * 1.08;
}
printf("%i年后,小甲鱼败光了所有的家产,再次回到一贫如洗", year);
return 0;
}
2.
#include <stdio.h>
int main()
{
double a, b, k;
double pai = 0;
for(a = 1, b = 1; a/b >= 0.00000001; b = b + 2)
{
int i = b;
if((i % 4) == 3)
{
k = -(a/b);
}
else if((i % 4) == 1)
{
k = a/b;
}
pai = pai + k;
}
float sum;
sum = 4*pai;
3.
#include <stdio.h>
int main()
{
int month, a, b, c;
a = 1;
b = 1;
for(month = 0; month <= 24; month++)
{
c = a + b;
a = b;
b = c;
}
printf("两年后共有%i对兔子",c);
return 0;
}
printf("Pi的近似值为%.7f",sum);
return 0;
}
3. |
|