Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class aufgabe5 {
- /**
- * @param args
- */
- public static void main(String[] args) throws Exception {
- char mark = 'a';
- char zeichen = '+';
- int zeichenLaenge = 7 ;
- int i = zeichenLaenge;
- //int j = 1;
- int zaehler;
- int wert;
- switch (mark){
- case 'a' :
- if (zeichenLaenge%2 != 0){ // prรผfen ob lรคnge durch 2 teilbar (ohne rest)
- for (int j = zeichenLaenge ; j >= 1; j -= 2){
- for (int c = 0; c <= (zeichenLaenge - j)/2 ; c++)
- System.out.print(" ");
- for (int c = 1; c <= j; c++)
- System.out.print(zeichen);
- System.out.println();
- }
- for (int j = 1 ; j <= zeichenLaenge; j += 2){
- for (int c = 0; c <= (zeichenLaenge - j)/2; c++)
- System.out.print(" ");
- for (int c = 1; c <= j ; c++)
- System.out.print(zeichen);
- System.out.println();
- }
- }
- else{
- for (int j = zeichenLaenge ; j >= 2; j -= 2){
- for (int c = 0; c <= (zeichenLaenge - j)/2 ; c++)
- System.out.print(" ");
- for (int c = 1; c <= j; c++)
- System.out.print(zeichen);
- System.out.println();
- }
- for (int j = 2 ; j <= zeichenLaenge; j += 2){
- for (int c = 0; c <= (zeichenLaenge - j)/2; c++)
- System.out.print(" ");
- for (int c = 1; c <= j ; c++)
- System.out.print(zeichen);
- System.out.println();
- }
- }
Add Comment
Please, Sign In to add comment