10 ;11 ;; ;
1
0. 10
1. 9
2. c=5, b=c, a=b
3.14 5 9
4. z= x>=0 ? x : -x
5.
0.
#include <stdio.h>
#include <math.h>
int main()
{
int year;
float a, b;
a = 10000;
b = 10000;
for(year = 0; a >= b; year++)
{
a = a + 10000*0.1;
b = b * 1.05;
}
printf("%i年后,黑夜的投资额超过小甲鱼!\n小甲鱼的投资额为%.2f元\n黑夜的投资额为%.2f元",year, a, b);
return 0;
}
1.
#include <stdio.h>
#include <math.h>
int main()
{
int year;
float a;
a = 400;
for(year = 0; a >= 0; year++)
{
a = (a-50) * 1.08;
}
printf("%i年后,小甲鱼败光了所有的家产,再次回到一贫如洗", year);
return 0;
}
2.
#include <stdio.h>
int main()
{
double a, b, k;
double pai = 0;
for(a = 1, b = 1; a/b >= 0.00000001; b = b + 2)
{
int i = b;
if((i % 4) == 3)
{
k = -(a/b);
}
else if((i % 4) == 1)
{
k = a/b;
}
pai = pai + k;
}
float sum;
sum = 4*pai;
3.
#include <stdio.h>
int main()
{
int month, a, b, c;
a = 1;
b = 1;
for(month = 0; month <= 24; month++)
{
c = a + b;
a = b;
b = c;
}
printf("两年后共有%i对兔子",c);
return 0;
}
printf("Pi的近似值为%.7f",sum);
return 0;
}
3.
。
0. 100个
1. 0个
2. a, b, c
3. a=14 b=5 c=9
4. z = (x>=0?x:-x)
5. if (size > 12)
{
cost = cost * 1.05;
flag = 2;
}
else
{
答案
1
1
#include <stdio.h>
int main() {
int n = 10000;
float y = n;
float h = n;
int count=0;
while(y>=h) {
y = y + n * (0.1);
h = h * (1+0.05);
count++;
}
printf("%d年后,黑夜的投资额将超过小甲鱼!\n", count);
printf("小甲鱼的投资额是: %.2f\n", y);
printf("黑夜的投资额是: %.2f\n", h);
return 0;
}
#include <stdio.h>
int main(){
float n = 4000000;
int time=0;
while(n > 0){
n -= 500000;
n *= 1.08;
time++;
}
printf("%d年之后,小甲鱼败光了所有家产,再次回到一贫如洗...",time);
return 0;
}
#include <stdio.h>
#include <math.h>
int main(){
int n=1;
float sum = 0,pi=0,i=0,x=1.0;
while(1){
i = x/n;
if(fabs(i)<10e-8){
break;
}
sum += i;
n += 2;
x = -x;
}
pi = 4*sum;
printf("pi = %f\n",pi);
}
#include <stdio.h>
int main (){
int n,a,b;
a = 0;
b = 1;
for(int i = 0;i < 24;i++){
n = a;
a = b;
b = n + b;
}
printf("%d",b*2);
}
从v你吃饭才能
1
1
0
{:5_111:}