Java :: Aufgabe #278
4 Lösungen
Das kleine Einmaleins
Anfänger - Java
von DragStar
- 06.04.2020 um 08:32 Uhr
Erstellen Sie ein Programm, welches das kleine Einmaleins in der Form
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 ...
.
.
.
10 20 30 40 50 60 70 80 90 100
ausgibt.
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 ...
.
.
.
10 20 30 40 50 60 70 80 90 100
ausgibt.
Lösungen:
public class main {
public static void main(String[] args) {
for(int i=1; i<=10; i++) {
for(int j=1; j<=10; j++) {
if(j<10) {
System.out.print(i*j+" ");
} else {
System.out.println(i*j);
}
}
}
}
}
public class Main {
public static void main(String[] args) {
new Main().multiplicator();
}
public void multiplicator(){
int [][] array = new int[10][10];
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10; j++) {
array[i-1][j-1] = i*j;
}
}
for ( int i = 0; i < array.length; i++ )
{ for ( int j=0; j < array[i].length; j++ )
System.out.print( array[i][j] + " ");
System.out.println();
}
}
}public class Einmaleins {
public static void main(String[] args) {
int N = 10;
// Schleife über alle Zahlen, die miteinander multipliziert werden
for(int ix = 1; ix <= N; ix++) {
for(int iy = 1; iy <= N; iy++) {
System.out.printf("%4s", ix*iy);
}
// Zeilenumbruch am Ende einer Zeile erzeugeni
System.out.println();
}
}
}
public class num {
public static void main(String args[]) {
int[] width = new int[11];
int[] height = new int[11];
//occupy
for(int i=0;i<width.length; i++) {
width[i]=i;
}
for(int i=0;i<height.length; i++) {
height[i]=i;
}
//calculate
for(int i=1;i<height.length;i++) {
for(int j=1;j<width.length;j++) {
System.out.print(width[j]*height[i]+" ");
if(j == 10) {
System.out.println("\n");
}
}
}
}
}
