Java:
int width= 25;
int heigth= 9;
int hyphenLength=19;
int hyphenStart= width-hyphenLength;
OUT: for(int i=0;i<heigth;i++)
{
INNER:for(int j=0;j<width;j++)
{
switch (i)
{
case 0:
if(j==0)
{
System.out.print("X");continue INNER;
}
if(j>0&j<hyphenStart||j>7&j<11)
{
System.out.print(" ");continue INNER;
}
if(j==7)
{
System.out.print("x\u00B2");continue INNER;
}
if(j==11)
{
System.out.print("x\u00B3");
}break;
case 1:
if(j<hyphenStart-1)
{
System.out.print(" ");
}
if(j>=hyphenStart&j<=hyphenLength){
System.out.print("-");
}break;
case 2:
if(j==0)
{
System.out.print(1);
}
if(j>0&j<hyphenStart||j>7&j<11)
{
System.out.print(" ");continue INNER;
}
if(j==7)
{
squareNumber(i);
}
if(j==11)
{
numberN3(i);
}break;
case 3:
if(j==0)
{
System.out.print(2);
}
if(j>0&j<hyphenStart||j>7&j<11)
{
System.out.print(" ");continue INNER;
}
if(j==7)
{
squareNumber(i);
}
if(j==11)
{
numberN3(i);
}break;
case 4:
if(j==0)
{
System.out.print(3);
}
if(j>0&j<hyphenStart||j>7&j<11)
{
System.out.print(" ");continue INNER;
}
if(j==7)
{
squareNumber(i);
}
if(j==11)
{
numberN3(i);
}break;
case 5:
if(j==0)
{
System.out.print(4);
}
if(j>0&j<hyphenStart||j>7&j<10)
{
System.out.print(" ");continue INNER;
}
if(j==7)
{
squareNumber(i);
}
if(j==11)
{
numberN3(i);
}break;
case 6:
if(j==0)
{
System.out.print(5);
}
if(j>0&j<hyphenStart||j>7&j<10)
{
System.out.print(" ");continue INNER;
}
if(j==7)
{
squareNumber(i);
}
if(j==11)
{
numberN3(i);
}break;
case 7:
if(j==0)
{
System.out.print(6);
}
if(j>0&j<hyphenStart||j>7&j<10)
{
System.out.print(" ");continue INNER;
}
if(j==7)
{
squareNumber(i);
}
if(j==11)
{
numberN3(i);
}break;
case 8:
if(j==0)
{
System.out.print(7);
}
if(j>0&j<hyphenStart||j>7&j<10)
{
System.out.print(" ");continue INNER;
}
if(j==7)
{
squareNumber(i);
}
if(j==11)
{
numberN3(i);
}break;
}
if(j==width-1)
{
System.out.println();
}
}
}
}
public static void squareNumber(int index){
System.out.print((int)Math.pow((index-1),2));
}
public static void numberN3(int index)
{
System.out.print((int)Math.pow((index-1),3));
}
Die Abstände sind so wie sie sein sollen in der Konsole^^. Bzw. so wie sie vorgegeben waren. Mir gefällt der Code nur nicht und ich suche nach einer kürzeren Lösung.X x² x³
--------------
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
Process finished with exit code 0