日期:2014-05-20 浏览次数:20727 次
(a),(b),(c),(d),(e),(f),(g),(h),(i)
(ab),(cd),(ef),(gh),(i)
(abc),(def),(ghi)
(abcd),(efgh),(i)
(abcde),(fghi)
(abcdef),(ghi)
(abcdefg),(hi)
(abcdefgh),(i)
(abcdefghi)
public class Test1 {
public static void main(String[] args) {
output('a', 'i');
}
private static void output(char start, char end) {
int count = end - start + 1;
int add = 1;
for (int i = 0; i < count; ++i, ++add) {
for (int j = 0; j < count; j += add) {
System.out.print("(");
for (int k = j; k < Math.min(j + add, count); ++k) {
System.out.print((char) (start + k));
}
System.out.print(")");
if(j + add < count) {
System.out.print(",");
}
}
System.out.println();
}
}
}