|
|
发表于 2018-12-27 18:05:52
|
显示全部楼层
0. 100次
1. 不打印
2. a b c
3. 14 5 9
4. z = x > 0? x : -x;
5.
if (size > 12)
{
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;
if (ibex > 14)
{
sheds = 3;
}
sheds = 2;
help = 2 * sheds;
if (score < 0)
{
printf("count = %d\n", count);
}
count++;
scanf("%d", &score);
0.
#include <stdio.h>
#define XJY 0.1
#define HY 0.05
int main()
{
int year = 0;
float xjy_money, hy_money;
xjy_money = hy_money = 10000;
do{
year++;
xjy_money += 10000 * XJY;
hy_money = hy_money * (1 + HY);
}while (xjy_money >= hy_money);
printf("%d年后,黑夜的投资额超过小甲鱼!\n", year);
printf("小甲鱼的投资额是:%.2f\n", xjy_money);
printf("黑夜的投资额是:%.2f\n", hy_money);
return 0;
}
1.
#include <stdio.h>
#define LI 1.08
#define QU 50.0
int main()
{
float surplus = 400.0;
int year = 0;
do{
year++;
surplus -= QU;
surplus *= LI;
}while (surplus >= 50);
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗……\n", year + 1);
return 0;
}
2.
#include <math.h>
int main()
{
double Pi = 0, i = 1;
while (fabs(1 / i) > pow((double)10, -8)){
Pi += 1 / i;
i = i < 0? -i + 2 : -(i + 2);
}
printf("%.7f\n", Pi);
return 0;
}
3.
#include <stdio.h>
int main()
{
long sum = 0, i = 1, j = 2, temp;
int time = 3;
for (; time <= 24; time++){
sum = i + j;
temp = j;
j = sum;
i = temp;
}
printf("震惊!2年后有%ld对兔子!\n", sum);
return 0;
}
|
|