题解 | #牛牛的水杯#
牛牛的水杯
https://www.nowcoder.com/practice/c196c47c23394bf3bdd4f82a838df6bf
#include <stdio.h> int main() { int h, r;//定义杯子的高度和半径 float total = 10000;//牛牛每天喝10L水,也就是10000ml scanf("%d %d", &h, &r);//输入杯子的高度和半径 float v = 0; v = 3.14 * h * r * r;//体积的公式 int bottle = total / v;//喝多少瓶 float decision = total / v - bottle;//用来判定有没有完整的喝完一瓶 if (decision == 0)//完整的喝完 { printf("%d\n", bottle); } else //最后一瓶没有完全喝完 { printf("%d\n", bottle + 1); } return 0; }#c语言基础#
C语言基础 文章被收录于专栏
里面较为详细的介绍了c语言的相关用法和有关题目。