Hallo,
habe folgenden Aufgabenteil "a)" zu machen.
Kann mir jemand helfen? Lösung der vorherigen aufgabe (hängt zusammen) isr folgende:
[code = java]
import java.util.Scanner;
public class seite11_aufgabe1{
public static void main(String[]args){
int a = 0;
int b = 0;
String eingabe;
System.out.println("Geben sie eine Spaltenanzahl ein: ");
Scanner scan = new Scanner(System.in);
int s = scan.nextInt();
System.out.println("Geben sie eine Spaltenanzahl ein: ");
int z = scan.nextInt();
int arr[][] = new int[z];
//Eingabe
for (int i = 0;i < z;i ++) {
for (int j = 0;j < s;j ++) {
System.out.print("Enter element for row = " + (i + 1) + " column = " + (j + 1) + " : ");
arr[j] = scan.nextInt();
}
}
for (int i = 0; i < z; i++) {
for (int j = 0; j < s; j++) {
System.out.print(arr[j] + " ");
}
System.out.println();
}
}
}
[/code]
__________
Die neue Aufgabe ist im BILD!
Danke für eure hilfe..
habe folgenden Aufgabenteil "a)" zu machen.
Kann mir jemand helfen? Lösung der vorherigen aufgabe (hängt zusammen) isr folgende:
[code = java]
import java.util.Scanner;
public class seite11_aufgabe1{
public static void main(String[]args){
int a = 0;
int b = 0;
String eingabe;
System.out.println("Geben sie eine Spaltenanzahl ein: ");
Scanner scan = new Scanner(System.in);
int s = scan.nextInt();
System.out.println("Geben sie eine Spaltenanzahl ein: ");
int z = scan.nextInt();
int arr[][] = new int[z]
//Eingabe
for (int i = 0;i < z;i ++) {
for (int j = 0;j < s;j ++) {
System.out.print("Enter element for row = " + (i + 1) + " column = " + (j + 1) + " : ");
arr[j] = scan.nextInt();
}
}
for (int i = 0; i < z; i++) {
for (int j = 0; j < s; j++) {
System.out.print(arr[j] + " ");
}
System.out.println();
}
}
}
[/code]
__________
Die neue Aufgabe ist im BILD!
Danke für eure hilfe..