|
发表于 2020-7-29 18:08:21
|
显示全部楼层
测试题:
0.
10个
1.
0个
2.
a,b,c
3.
14,5,9
4.
#include <stdio.h>
int main()
{
int x, z;
scanf("%d", &x);
z= x>=0 ? x: -x;
printf("z=|x|=%d\n", z);
return 0;
}
5.
A.
if (size > 12)
{
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;
B.
if (ibex > 14)
{
sheds = 3;
help = 2 * sheds;
}
else
{
sheds = 2;
sheds = 3;
help = 2 * sheds;
}
C.
do
{
scanf("%d", &score);
if(score>=0)
{
count++;
}
}while(score>=0)
printf("count = %d\n", count);
动动手:
0.
#include <stdio.h>
int main()
{
float xjy=10000, hy=10000, lx1, lx2;
int count=0;
while(hy<=xjy)
{
lx1=10000*0.1;
lx2=hy*0.05;
xjy=xjy+lx1;
hy=hy+lx2;
count++;
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n",count);
printf("小甲鱼的投资额是:%.2f\n",xjy);
printf("黑夜的投资额是:%.2f\n",hy);
}
1.
#include <stdio.h>
int main()
{
float zh=400;
int count=0;
while(zh>0)
{
zh=zh-50;
zh=zh+zh*0.08;
count++;
}
printf("%d年后,小甲鱼败光了所有家产,再次回到一贫如洗…",count);
}
2.
#include <stdio.h>
#include <math.h>
int main()
{
float pi1=1, pi2;
int c=1, i=-1;
do
{
c=c+2;
pi1=pi1+i*1.0/c;
i=-i;
pi2=4*pi1;
}while(1.0/c >= pow(10, -8));
printf("pi=%.7f", pi2);
}
3.
#include <stdio.h>
int main()
{
int count=0, i1=1, i2=0, i3=0, rb=2;
i3=i1;
count++;
while(count<=24)
{
i1=i1+i2;
i2=i3;
i3=i1;
rb=i1+i2+i2;
count++;
}
printf("两年后共有兔子%d对", rb);
} |
|