问题:有两组范围数字:474~514,783~813两组范围数字(**范围数字会变化**)。
实际范围数字有很多组,且数字范围变化
通过程序处理,输出格式为:
474,475,476,477,478,479,480
481,482,483,484,485,486,487,488,489,490
491,492,493,494,495,496,497,498,499,500
501,502,503,504,505,506,507,508,509,510
511,512,513,514
783,784,785,786,787,788,789,790
791,792,793,794,795,796,797,798,799,800
801,802,803,804,805,806,807,808,809,810
811,812,813
public class Test {
public static void main(String[] args) {
for (int i = 474; i <= 514; i++) {
if (i != 514) {
if(i%10==0){
System.out.print(i);
System.out.println("");
}else{
System.out.print(i + ",");
}
} else {
System.out.print(i);
}
}
System.out.println("");
for (int i = 783; i <= 813; i++) {
if (i != 813) {
if(i%10==0){
System.out.print(i);
System.out.println("");
}else{
System.out.print(i + ",");
}
} else {
System.out.print(i);
}
}
}
}
public static void main(string[] args){
for(int i=474;i<=514;i++){
if(i!=514){
system.out.print(i+",")
}else{
system.out.print(i)
}
}
system.out.println("");
for(int i=783;i<=813;i++){
if(i!=813){
system.out.print(i+",")
}else{
system.out.print(i)
}
}
}
@Test
public void test() {
for (int i = 474; i <= 514; i++) {
if ((i % 10) != 0 && i != 514) {
System.out.print(i + ",");
} else {
System.out.println(i);
}
}
for (int i = 783; i <= 813; i++) {
if ((i % 10) != 0 && i != 813) {
System.out.print(i + ",");
} else {
System.out.println(i);
}
}
}
//以上代码亲测结果一致
