![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
实际问题
youfuwenn
所有内容的主要目的是自我学习
展开
-
街上有 n 栋房子整齐地排成一列,每栋房子都粉刷上了漂亮的颜色。给你一个下标从 0 开始且长度为 n 的整数数组 colors ,其中 colors[i] 表示第 i 栋房子的颜色。2078.
class Solution {public: int maxDistance(vector<int>& colors) { int i = 0; int j = 0; int res = 0; for (i = 0; i<colors.size(); i++) { for (j = i + 1; j<colors.size(); j++) { if (colors[i] != colors[j]) { res .原创 2021-11-23 15:04:09 · 666 阅读 · 0 评论 -
喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少瓶汽水。编程实现。
int main(){ int a = 20; int he = 0; int kong = 0; he = a; kong = he; while (kong > 1)//只要空瓶有两个或以上就能继续换来喝。 { he = he + kong / 2; kong = kong / 2 + kong % 2; } printf("%d\n", he); return 0;}原创 2021-10-27 12:30:03 · 271 阅读 · 0 评论