|
发表于 2022-7-26 15:12:35
|
显示全部楼层
0.10个
1.0个
2.a,b,c
3.a=14,b=5,c=9;
4.z=(x>0)?x:-x;
5.A
if (size > 12)
{
cost = cost * 1.05;
flag = 2;
bill = cost * flag;
}
else
{
bill = cost * flag;
}
B
if (ibex > 14)
{
sheds = 3;
help = 2 * sheds;
}
else
{
sheds = 2;
help = 2 * sheds;
}
C
scanf("%d", &score);
while (score > 0)
{
count++;
scanf("%d", &score);
}
printf("count = %d\n", count);
0.
#include <stdio.h>
int main()
{
float num1=10000.00,num2=10000.00,lx1=0.00,lx2=0.00;
int count=0;
do
{
lx1=10000*0.1;
num1=num1+lx1;
lx2=num2*0.05;
num2=num2+lx2;
count++;
}
while (num1>num2);
printf("%d年后,黑夜的投资额超过小甲鱼!\n", count);
printf("小甲鱼的投资额是:%.2f\n",num1);
printf("黑夜的投资额是:%.2f\n",num2);
return 0;
}
1.
#include <stdio.h>
int main()
{
float num=4000000.00,lx=0.00;
int count=0;
do
{
num=num+lx-500000.00;
lx=num*0.08;
count++;
}
while (num>0);
printf("%d年后,小甲鱼败光了所有的家产,再次回到一贫如洗...\n", count);
return 0;
}
2.
#include <stdio.h>
#include <math.h>
int main()
{
float num1=0,i,temp=0,num2=0;
for(i=1;(fabs(temp))>(10^(-8));i=-i)
{
num2=num1;
num1+=1/i;
if(i>0)
{
i+=2;
}
else
{
i-=2;
}
temp=num1-num2;
}
printf("pi的近似值为:%f\n", num1*4);
return 0;
}
3.
#include <stdio.h>
#include <math.h>
int main()
{
int num=2,i,temp=2,ltemp=1;
for(i=3;i<24;i++)
{
temp+=ltemp;
ltemp=temp-ltemp;
num+=temp;
}
printf("兔子数为:%d\n", num*2);
return 0;
}
|
|