blob: 7e744a3c1cefca67f57ef05f4861780a83c71548 (
plain) (
blame)
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
42
43
44
45
46
47
48
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
//horrible recursive for loops are not fun
//they aren't a good way to teach something
//why can't we do fizzbuzz?
//or make small games?
//or do data manipulation?
//or solve a problem?
//or something more enjoyable than this?
//maybe CS really should stay a hobbiest, self taught skill
//at least when its a hobby you learn what matters at your own pace
//here its just being given an unrealistic task that, albiet difficult, is not rewarding
//making a diamond like this doesn't teach me good programming
//it teaches me for loops
//and nested for loops are usually not a good way to go about things
//I just want to make command line tools and data parsers for gods sake!
//maybe mom was right, I should just go for law
//sysadmining seems nice though, I could do that
//yeah, law or sysadmin. That seems nice
//or I could write and edit for a living, that doesn't seem too bad
class Diamond {
public static void main(String[] args) throws java.io.IOException {
BufferedReader dmndsizeI = new BufferedReader(new InputStreamReader(System.in));
System.out.println("input size");
int dmndsize = Integer.parseInt(dmndsizeI.readLine());
for (int i = 1; i < dmndsize; i += 2) {
for (int j = 0; j < dmndsize -1 - i / 2; j++)
System.out.print(" ");
for (int j = 0; j < i; j++)
System.out.print("*");
System.out.print("\n");
}
for (int i = 7; i > 0; i -= 2) {
for (int j = 0; j < 9 - i / 2; j++)
System.out.print(" ");
for (int j = 0; j < i; j++)
System.out.print("*");
System.out.print("\n");
}}}
//By msglm; Licensed under the AGPL v3
|