题解 1072: 汽水瓶

来看看其他人写的题解吧!要先自己动手做才会有提高哦! 
返回题目 | 我来写题解

筛选

使用递归完成解题,代码清晰可读

摘要:解题思路:使用函数递归,返回两个数值,分别是空水瓶数和已购水瓶数,当空水瓶数=2时,返回值加1(如题所述),<2时,直接返回代码结构如下:注意事项:在编写代码途中,需要注意适当增加变量保存水瓶数,如变……

汽水瓶,简单递归法

摘要:解题思路:注意事项:参考代码:#include"bits/stdc++.h" using namespace std; // 全局变量,用于记录最终结果,及换了多少汽水喝 int c=0; v……

用小学生思路解决此题

摘要:解题思路:枚举注意事项:参考代码:#include<stdio.h>int main(){ int a[10];int i=0,m=1;while(m){    scanf("%d",&a[i]); ……

汽水瓶:第二种解法

摘要:解题思路:注意事项:参考代码:#include <stdio.h>#include <string.h>int main(){ int n,b,a,m,j=0; while(scanf("%d",&n……

汽水瓶:n/2

摘要:解题思路:注意事项:参考代码:#include<stdio.h>int main(){    int i=-1,j,n[100];    do{        scanf("%d",&n[++i]);……

逆天解法,包得吃的。

摘要:解题思路:注意事项:参考代码:#include<stdio.h>int main(){ int n; while(~scanf("%d",&n)) { int b,a=0,c=0; if(n……

递归思想解题

摘要:解题思路:注意事项:参考代码:#include<iostream>using namespace std;int s=0;int F(int n){    if(n<2){        return……

汽水瓶(dfs法)

摘要: import java.util.Scanner; public class Main { static int dfs(int n){ ……