|
发表于 2022-3-3 20:35:31
|
显示全部楼层
0、100个
1、11个
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;
B:
if (ibex > 14)
{
sheds = 3;
}
sheds = 2;
help = 2 * sheds;
C:
while((scanf("%d", &score))==1)
if (score < 0)
{
printf("count = %d\n", count);
}
count++;
}
0、
#include<stdio.h>
#include<math.h>
int main()
{
float total1=10000.00;
float total2=10000.00;
int year;
float r1=0.1,r2=0.05;
float r=total1*r1;
for(year=0;total1>=total2;year++)
{
total1=total1+r;
total2=total2+total2*r2;
}
printf("%d年后,黑鱼的投资额超过小甲鱼!\n",year);
printf("小甲鱼的投资额是:%.2f\n",total1);
printf("黑鱼的投资额是:%.2f\n",total2);
return 0;
}
1、#include<stdio.h>
int main()
{
long long sum=4000000,i=500000;
int year;
for(year=0;sum>0;year++)
{
sum=(sum-i)*(1+0.08);
}
printf("%d年后,小甲鱼败光了所有的家产,再次回到一贫如洗……",year);
return 0;
}
2、
#include<stdio.h>
#include<math.h>
int main()
{
float Pi,p=1,i=1,j=1,sum=0;
while(p>=0.00000001)
{
p=1/j;
sum=sum+i*p;
i=-i;
j+=2;
}
Pi=sum*4;
printf("Pi=%.7f",Pi);
return 0;
}
3、#include<stdio.h>
int main()
{
int month;
long long count=1,temp;
for(month=2;month<=24;month++)
{
temp=count;
count=count+temp;
}
printf("两年之后可以繁殖%lld对兔子。\n",count);
return 0;
}
|
|