---
title: "Java编程练手100题"
author: "MouseLearnJava"
date: "2014-12-11T17:13:29Z"
tags: []
categories: ["编程语言"]
slug: "java-100"
draft: false
lastmod: "2014-12-11T17:13:29Z"
id: 2165577
url: "https://mouselearnjava.iteye.com/blog/2165577"
---

本文给出100道Java编程练手的程序。

列表如下：

## 面试编程

001. [写一个程序，去除有序数组中的重复数字](http://thecodesample.com/?p=701)
002. [编写一个程序使得两个线程陷入死锁](http://thecodesample.com/?p=710)
003. [使用递归算法反转字符串](http://thecodesample.com/?p=712)
004. [合并两个有序数组](http://thecodesample.com/?p=731)
005. [找出三个有序数组共有的元素](http://thecodesample.com/?p=735)
006. [字符(字母、数字、中文字符)统计示例](http://thecodesample.com/?p=738)
007. [最短时间过桥](http://thecodesample.com/?p=63)
008. [从一个整数数组中找出总和为S的所有子集](http://thecodesample.com/?p=66)
009. [5个钢珠离开凹轨的最短时间和最长时间](http://thecodesample.com/?p=97)
010. [1到50个数，每次去掉两个数，增加两个数差的绝对值，最后剩什么数？为什么？](http://thecodesample.com/?p=154)
011. [输出全排列](http://thecodesample.com/?p=131)
012. [随机产生和为S的N个正整数](http://thecodesample.com/?p=146)
013. [Java洗牌](http://thecodesample.com/?p=171)
014. [判断一个集合能否分成和一致的两个子集合，并且输出其中一半的子集内容。](http://thecodesample.com/?p=225)
015. [归并排序Java实现](http://thecodesample.com/?p=274)
016. [快速排序Java实现](http://thecodesample.com/?p=418)
017. [列出拥有M个元素集合的含有N个元素的所有子集](http://thecodesample.com/?p=288)
018. [计算非负数二进制形式中1的个数](http://thecodesample.com/?p=291)
019. [将数组分割成差值最小的子集](http://thecodesample.com/?p=282)
020. [统计给定数组中0的个数](http://thecodesample.com/?p=327)
021. [三个线程循环打印ABC10次](http://thecodesample.com/?p=425)
022. [河内塔](http://thecodesample.com/?p=412)
023. [重排数组使得array\[i\]等于array\[array\[i\]\]，但只能用0(1)的额外空间](http://thecodesample.com/?p=470)
024. [打印一个数组所有的非空子集](http://thecodesample.com/?p=468)
025. [连续数字的旋转二维数组](http://thecodesample.com/?p=501)
026. [寻找数组中只出现一次的数](http://thecodesample.com/?p=499)
027. [有四个线程1、2、3、4。线程1的功能就是输出A，线程2的功能就是输出B，以此类推…](http://thecodesample.com/?p=489)
028. [所有数值为0的元素置于数组最后](http://thecodesample.com/?p=487)
029. [一个线程打印 1~52,另一个线程打印字母A-Z。打印顺序为12A34B56C……5152Z](http://thecodesample.com/?p=472)
030. [还剩余多少盏灯亮着](http://thecodesample.com/?p=518)
031. [列出走楼梯或者台阶的所有走法](http://thecodesample.com/?p=516)
032. [从一个整数数组中找出总和为S的所有子集](http://thecodesample.com/?p=66)
033. [最大连续子序列和](http://thecodesample.com/?p=577)
034. [去除有序数组中的重复数字](http://thecodesample.com/?p=701)
035. [找出三个有序数组共有的元素](http://thecodesample.com/?p=735)
036. [字符(字母、数字、中文字符)统计示例](http://thecodesample.com/?p=738)
037. [合并两个有序数组](http://thecodesample.com/?p=731)
038. [使用递归算法反转字符串](http://thecodesample.com/?p=712)
039. [找出数组中出现次数超过一半的数](http://thecodesample.com/?p=763)
040. [给定一个字符集合S和一个正整数K，输出长度为K的所有组合](http://thecodesample.com/?p=775)
041. [给定一个只有0,1,2的数组，只用一个循环将该数组排序](http://thecodesample.com/?p=778)
042. [如果在数据范围\[0, 2^x - 1\]中少了一个数，这个数是哪一个呢?](http://thecodesample.com/?p=786)
043. [给定一个数组和一个指定的sum值，给出所有的和为sum的元素对](http://thecodesample.com/?p=792)
044. [奇数魔方阵](http://thecodesample.com/?p=805)
045. [两个线程轮换打印1-100内的奇数和偶数](http://thecodesample.com/?p=814)
046. [给定两个有序数组和一个指定的sum值，从两个数组中各找一个数使得这两个数的和与指定的sum值相差最小](http://thecodesample.com/?p=855)
047. [随机产生字母和数字的字符串](http://thecodesample.com/?p=916)
048. [找出10万以内的亲和数](http://thecodesample.com/?p=844)
049. [给定一个数组，其中一个元素只出现一次，其余所有的元素都出现3次，找出这个只出现一次的数](http://thecodesample.com/?p=841)
050. [用位运算交换两个数，不使用任何类型的额外变量](http://thecodesample.com/?p=829)
051. [输入一个整数数组，调整数组中数字的顺序，使得所有奇数位于所有偶数的前面](http://thecodesample.com/?p=824)
052. [用1、2、2、3、4、5这六个数字，用java写一个main函数，打印出所有不同的排列，如：512234、412345等，要求：”4″不能在第三位，”3″与”5″不能相连。](http://thecodesample.com/?p=879)
053. [在一个字符串中找到第一个只出现一次的字符](http://thecodesample.com/?p=882)
054. [找出缺失的一个数](http://thecodesample.com/?p=930)
055. [找出两个有序数组中的共同元素](http://thecodesample.com/?p=897)
056. [合并两个有序整数数组并去除其中的重复元素](http://thecodesample.com/?p=894)
057. [随机产生由特殊字符，大小写字母以及数字组成的字符串，且每种字符都至少出现一次](http://thecodesample.com/?p=935)
058. [打印所有可能的括号组合](http://thecodesample.com/?p=946)
059. [判断一个字符串中的字符是否都只出现一次](http://thecodesample.com/?p=951)
060. [寻找丑数](http://thecodesample.com/?p=958)
061. [按字节截取字符串](http://thecodesample.com/?p=1012)
062. [3个线程依次打印递增的数字(二)](http://thecodesample.com/?p=1024)
063. [使用多线程统计1到一千万之间有多少个素数](http://thecodesample.com/?p=1161)
064. [有1、2、3、4个数字，能组成多少个互不相同且无重复数字的三位数？都是多少？](http://thecodesample.com/?p=1038)
065. [有一个已经排好序的数组。现输入一个数，要求按原来的规律将它插入数组中](http://thecodesample.com/?p=1041)
066. [使用Executor求出10000个随机数据中的top 100](http://thecodesample.com/?p=1047)
067. [给定一个无序整数数组，找出第K个最小的数字](http://thecodesample.com/?p=1050)
068. [已知一个正整数N，问从1~N-1中任选出三个数，他们的最小公倍数最大可以为多少?](http://thecodesample.com/?p=1056)
069. [请在小于99999的正整数中找符合下列条件的数，它既是完全平方数，又有两位数字相同，如：144，676。](http://thecodesample.com/?p=1061)
070. [找出没有被放入数组的那2个数](http://thecodesample.com/?p=1065)
071. [求解所有可能的数字集合，使用Stack实现](http://thecodesample.com/?p=1069)
072. [在数组中查找两个和为指定数值的数](http://thecodesample.com/?p=1076)
073. [计算有多少种爬楼梯的方式(递归)](http://thecodesample.com/?p=1081)
074. [计算有多少种爬楼梯的方式(非递归)](http://thecodesample.com/?p=1083)
075. [\[Leetcode\] 3Sum](http://thecodesample.com/?p=1087)
076. [\[Leetcode\] Two Sum](http://thecodesample.com/?p=1093)
077. [\[Leetcode\] 4Sum](http://thecodesample.com/?p=1096)
078. [\[Leetcode\] Regular Expression Matching](http://thecodesample.com/?p=1099)
079. [\[Leetcode\] Container With Most Water](http://thecodesample.com/?p=1103)
080. [\[Leetcode\] Triangle](http://thecodesample.com/?p=1109)
081. [\[Leetcode\] Remove Duplicates from Sorted Array](http://thecodesample.com/?p=1113)
082. [\[Leetcode\] Spiral Matrix](http://thecodesample.com/?p=1119)
083. [\[Leetcode\] Longest Substring Without Repeating Characters](http://thecodesample.com/?p=1123)
084. [\[Leetcode\] Maximum Subarray](http://thecodesample.com/?p=1128)
085. [\[Leetcode\] Pascal’s Triangle II](http://thecodesample.com/?p=1134)
086. [\[Leetcode\] Single Number](http://thecodesample.com/?p=1142)
087. [\[Leetcode\] Spiral Matrix II](http://thecodesample.com/?p=1144)
088. [\[Leetcode\] \[Leetcode\] Maximum Product Subarray](http://thecodesample.com/?p=1146)
089. [\[Leetcode\] Combinations (采用位掩码实现)](http://thecodesample.com/?p=1148)
090. [\[Leetcode\] Set Matrix Zeroes](http://thecodesample.com/?p=1157)
091. [找出正整数组合的最小数](http://thecodesample.com/?p=1182)
092. [找出连续自然数的个数及其区间](http://thecodesample.com/?p=1188)
093. [三个线程轮流打印递增的数字(使用Lock和Condition实现)](http://thecodesample.com/?p=1193)
094. [三个线程轮流打印递增的数字(使用AtomicInteger实现)](http://thecodesample.com/?p=1191)
095. [三个线程轮流打印递增的数字(使用Semaphore实现)](http://thecodesample.com/?p=1199)
096. [5个砝码，重量分别是1，3，9，27，81。则它们可以组合称出1到121之间任意整数重量(穷举法)](http://thecodesample.com/?p=1279)
097. [5个砝码，重量分别是1，3，9，27，81。则它们可以组合称出1到121之间任意整数重量(回溯法)](http://thecodesample.com/?p=1283)
098. [5个砝码，重量分别是1，3，9，27，81。则它们可以组合称出1到121之间任意整数重量(十进制转三进制法)](http://thecodesample.com/?p=1285)
099. [输入一个正整数X，在等式 1 2 3 4 5 6 7 8 9 = X左边的数字之间添加+号或者-号，使得等式成立](http://thecodesample.com/?p=1288)
100. [解数独](http://thecodesample.com/?p=1242)

更多例子请访问[http://thecodesample.com/](http://thecodesample.com/)