第十六课 捡回来!
参考答案
111
111
#include <stdio.h>
#include <math.h>
int main(){
int tu;
int month =3;
tu=3;
int sum = 1;
for(int i =1; i<=100000 ; i++){
tu = 0;
}
while (month <= 24){
for(int i =0; i<=100000 ; i++){
if(tu>=2){
sum++;
}
}
printf("第%d个月的sum:%d\n",month,sum);
for(int j = 0; j <= sum-1 ; j++){
tu++;
}
month++;
}
printf("共有%d只兔子",sum*2);
return 0;
}
谢谢老板
// 0.打印10次1.10times 2.c b a 3.a=15,b,5,c=10
好
我要复习
1
1
本帖最后由 梦之浮栋 于 2020-3-7 08:54 编辑
0.10
1.0
2.a,b,c
3.15,5,9
4.z = x > 0 ? x : -x;
{:5_105:}
支持楼主
0. 0到9共10个A
2. 0个
3.a = b
b = c
c = 5
4.sqrt(double x**2)==z
5.if (size > 12)
{
putchat ('a')
break;
}
putchat ('b');
a: cost = cost * 1.05;
flag = 2;
b: bill = cost * flag;
if (ibex > 14)
{
putchat ('a')
break;
}
sheds = 2;
putchat ('b')
a: sheds = 3;
b: help = 2 * sheds;
动动手:
学习
0.100
1.10
2.c=5 b=c a=b
3.14 5 9
4.z=(x>0)?x:(-x)
5.if (size > 12)
{
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;
if (ibex > 14)
{
sheds = 3;
}
help = 2 * sheds;
if (score < 0)
{
printf("count = %d\n", count);
}
count++;
scanf("%d", &score);
最后一题:新增兔子数量等于两个月前数量的总和。用数组会简单些吧。
算兔子那道题,答案太巧妙了! 将a作为当月新增兔子数,b作为上个月累计的所有兔子数,c作为当月兔子累计的所有兔子数。由于,下个月的新增兔子数等于恰好等于上个月累计的所有兔子数,所以正好可以将b赋给a,同时将c赋给b,进而开始下一轮循环。我还傻啦吧唧地用数组才做出来。答案这个方法真是喵喵喵喵!
#include <stdio.h> //如果说兔子在出生两个月后,就有繁殖能力,在拥有繁殖能力之后
int main() //这对兔子每个月能生出一对小兔子来。假设所有兔子都不会死去,
{ //能够一直干下去,那么两年之后可以繁殖多少对兔子呢?
int month; //月数
int amount; // 每个月新增的兔子数量
int total; // 兔子总量(对)
amount = 0;
total = 1;
amount = 0;
total = 1;
for(month = 3; month <= 24; month++)
{
amount = total; // 当月新增的兔子数量等于两个月前的所有兔子总数
total = total + amount;
}
printf("两年后一共有:%d对兔子", total);
return 0;
}
来了来了