# [编程题1] 汽水瓶

3
10
81
0

1
5
40

## 题目分析及实现

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int bottle[] = new int[11];
int time = 0;
while (in.hasNext()) {
int numOfBottle = in.nextInt();
System.out.println(count(numOfBottle));
if (numOfBottle == 0)
break;

}
in.close();
}

public static int count(int num) {
int count = 0;
count = num / 3;
num = num % 3 + count;

if (num < 2)
return count;
else if (num == 2) {
return count + 1;
} else
return count += count(num);
}
}


# [编程题2] 明明的随机数

Input Param

n 输入随机数的个数

inputArray n个随机整数组成的数组

Return Value

OutputArray 输出处理后的随机整数

11
10
20
40
32
67
40
20
89
300
400
15

10
15
20
32
40
67
89
300
400

## 题目分析及实现

import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int n = in.nextInt();
int home[] = new int[1001];//从一开始算，1000个
Arrays.fill(home, 0);
for (int i = 0; i < n; i++) {
int num = in.nextInt();
if (home[num] == 0)
home[num] = 1;
}
for (int i = 1; i <= 1000; i++) {
if (home[i] == 1)
System.out.println(i);
}
}

}
}


# [编程题3] 进制转换

0xA

10

## 题目分析及实现

import java.util.Scanner;

public class Main3 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String input = in.next();
int output = 0;
double time = 0 ;
char []count = input.toCharArray();
for(int i =count.length-1;i>=2;i--) {//不遍历到最后两个
if(count[i]<='9')//数字和字符不连续，分开判断了
output +=(count[i]-'0')*Math.pow(16, time);
else
output +=(count[i]-'A'+10)*Math.pow(16, time);
time++;//权重
}
System.out.println(output);
}

}
}



05-13

11-24
11-17
08-08
08-08 3397
07-01 581
03-23 3684
04-02 1200
08-21 702
04-05 4317
09-16 191
07-10 9109
03-23 1280
07-03 404