|
发表于 2018-1-9 22:03:59
|
显示全部楼层
测试题
0.
10个’A’
1.
不会打印
2.
a,b,c
3.
a = 14, b = 5, c = 9;
4.
#include<stdio.h>
int main()
{
float x, z;
printf("Please input the value of x:");
scanf("%f",&x);
z = x >= 0? x: (-1)* x;
printf("|x| = %f\n",z);
return 0;
}
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.
do
{
scanf(“%d”, &score);
count++;
}while(score >= 0);
printf(“count = %d\n”, count);
动动手
0.
#include<stdio.h>
#include<math.h>
int main()
{
float fishc = 10000, night = 10000;
int year = 0;
while(night <= fishc)
{
fishc = 10000 + (10000 * 0.1) * year;
night =10000 * pow( (1 + 0.05) , year);
year++;
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n",year);
printf("小甲鱼的投资额是:%.2f\n黑夜的投资额是:%.2f\n",fishc, night);
return 0;
}
1.
#include<stdio.h>
int main()
{
double fishc = 400;
int year = 0;
while(fishc > 0)
{
fishc -= 50;
fishc = fishc * (1 + 0.08);
year++;
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗……",year);
return 0;
}
2.
#include<stdio.h>
int main()
{
double pi, temp, temp2, n = 1, sum = 0;
int i = 1;
do
{
temp = 1 / n;
if(temp < 0.00000001)
{
break;
}
temp2 = i * temp;
sum = sum + temp2;
i = -i;
n += 2;
}while(1);
pi = 4 * sum;
printf("pi = %.7lf",pi);
return 0;
}
3.
#include<stdio.h>
int main()
{
int month, sum = 0;
for(month = 24; month > 0; month -= 2)
{
sum += month;
}
printf("两年后可繁殖%d对兔子",sum);
return 0;
}
|
|