forked from ArinaJur/CodingPracticeLessons
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAscSeqNumbers.java
More file actions
41 lines (33 loc) · 1.02 KB
/
AscSeqNumbers.java
File metadata and controls
41 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package print;
public class AscSeqNumbers {
// 1. Print 1, 2, 3, 4, 5
// Идеи:
// конкатенация (а + b), печать строки ("1, 2..."), печать массива
//If 1000? if 1000000?
//for
//
//for c параметрами
//особое условие для 5 - if
//_______________________________________________________
//Написать метод, печатающий 1, 2, 3, 4, 5
static String str = ", ";
// public static void numbers(int num, String str) {
// for (int i = 1; i <= 5; i ++) {
// if (i == 5) {
// System.out.print(i);
// } else {
// System.out.print(i + str);
// }
// }
// }
public static void numbers (int num) {
for (int i = 1; i < num; i ++) {
System.out.print(i + str);
}
System.out.println(num);
}
public static void main(String[] args) {
numbers(5);
System.out.println();
}
}