|
发表于 2021-11-23 21:46:47
|
显示全部楼层
#include <stdio.h>
#include <math.h>
int main()
{
long double least, result, x;
int a, b, c, i;
a = b = 1;
i = 1;
c = 2;
x = a / b;
least = pow(10, -8);
result = 0;
while(x > least)
{
result = i * x + result;
b = b + c;
x = a / b;
i = -i;
}
printf("四分之Π的近似值是:%.7f", result);
return 0;
}
#include <stdio.h>
int main()
{
int money, year, cost;
float lixi;
money = 400;
year = 0;
cost = 50;
lixi = 0.08;
while (money > 0)
{
money = money - cost;
money = money + money * lixi;
year++;
}
printf("经过了%d年,小甲鱼一贫如洗!", year);
return 0;
}
#include <stdio.h>
int main()
{
int year, J_money, H_money, money;
float J_lixi, H_lixi;
money = 10000;
J_money = 10000;
H_money = 10000;
J_lixi = 0.1;
H_lixi = 0.05;
year = 0;
while (J_money >= H_money)
{
J_money = money * J_lixi + J_money;
H_money = H_money * H_lixi + H_money;
year++;
}
printf("经过了%d年!\n", year);
printf("小甲鱼有%d的钱!\n", J_money);
printf("黑夜有%d的钱!\n", H_money);
return 0;
}
#include <stdio.h>
int main()
{
while(1)
{
scanf("%d,", &score);
if (score < 0)
{
printf("count = %d\n", count);
break;
}
else
{
count++;
}
}
return 0;
}
#include <stdio.h>
int main()
{
int ibex, a = 14, b = 2, sheds, help;
scanf("%d", &ibex);
if (ibex > a)
{
sheds = 3;
}
else
{
sheds = 2;
help = 2 * sheds;
}
return 0;
}
#include <stdio.h>
int main()
{
int size, a, b;
float cost, bill;
scanf("%d", &size);
if (size > 12)
{
cost = cost * 1.05;
}
else
{
bill = cost * flag;
}
return 0;
} |
|