#include <stdio.h>
#include <stdlib.h>
int main()
{
int appleh[10], benchh, taoh, bentaoh, i;
benchh = 30; //板凳的高度
for (i=0; i<10; i++) //循环输入苹果的高度
{
scanf("%d", &appleh[i]);
}
scanf("%d", &taoh); //输入淘淘的高度
bentaoh = benchh + taoh; //淘淘站在板凳上的高度
int n = 0;
for (i=0; i<10; i++) //判断能否摘到苹果
{
if(appleh[i] <= bentaoh)
{
n++; //如果能够摘到苹果计数加一
}
}
printf("%d\n", n);
return 0;
}
转载于:https://www.cnblogs.com/Tristan-Adams/p/9762467.html
本文介绍了一个简单的C语言程序,用于模拟淘淘站在不同高度的板凳上摘取一系列高度不等的苹果。程序通过比较淘淘站在板凳上的总高度与各苹果的高度,判断淘淘能摘到多少个苹果,并输出该数量。

1042

被折叠的 条评论
为什么被折叠?



