public class Jump {
/*1-100号人循环报数,报到7的倍数的输出,第一轮输出7,14,...,98,第二轮99报1
输出5,13,....,不管是第几轮,输出完50个数结束。*/
public static void main(String[] args) {
int arr_all[] = new int[101];
int m = 1;
int i = 1;
int out = 0;
int count = 0;
for (; i <= 100; i++, m++) {
arr_all[m] = i;
}
while (out <= 50) {
for (i = 1; i <= 100; i++, m++) {
// 判断值是否 >100
if (i > 100) {
// 不报数 并输出
int p = 0;
p = i / 100;
out++;
System.out.print(p + "\t");
} else if (i <= 100) {
// <100 则 报数后判断是否x100并输出
count++;
System.out.println(count);
if (count == 7) {
count = 0;
arr_all[m] = i * 100;
}
}
// 判断角标 并重置角标
if (m == 100) {
m = 0;
}
}
}
}
}
if (i > 100)
这个判断纯粹多余
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
int arr_all[] = new int[100];
int i = 0;
for (; i < 100; i++) {
arr_all[i] = i + 1;
}
int out = 0;
i = 0;
int count = 0;
while (out <= 50)
{
if (arr_all[i % 100] != 0)
{
count++;
if (count % 7 == 0)
{
out++;
System.out.println(arr_all[i % 100]);
arr_all[i % 100] = 0;
count = 0;
}
}
i++;
}
}
}
在线编译通过
http://ideone.com/YYRKCu
7
14
21
28
35
42
49
56
63
70
77
84
91
98
5
13
22
30
38
46
54
62
71
79
87
95
3
12
23
32
41
51
60
69
80
89
99
9
19
31
43
53
65
75
86
97
10
24
36
48
61