1. Dashboard
  2. Forum
    1. Unerledigte Themen
  3. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team-Mitglieder
    4. Trophäen
    5. Mitgliedersuche
  4. Tutorial Bereich
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Seiten
  • Forum
  • Lexikon
  • Erweiterte Suche
  1. Informatik Forum
  2. Mitglieder
  3. JohannesSp

Beiträge von JohannesSp

  • Anzahl der Gerueste

    • JohannesSp
    • 3. Juni 2006 um 14:14

    import java.awt.Dimension;
    import java.util.ArrayList;

    import javax.swing.JTable;

    /*
    * Created on 03.04.2006
    *
    * To change the template for this generated file go to
    * Window>Preferences>Java>Code Generation>Code and Comments
    */
    /**
    *
    *
    * To change the template for this generated type comment go to
    *
    * Window>Preferences>Java>Code Generation>Code and Comments
    */

    public class AG3
    {
    private int n, j = 0;
    private double werte;
    private double[][] mat, mat2;
    private JTable jt;
    private boolean zusammenhaengend, uebergabe;
    private int[] anzahl;

    public AG3(int wert, JTable tab, boolean uebergabe)
    {
    n = wert;
    jt =null;
    jt = tab;
    mat = new double[n][n];
    mat2 = new double[n][n];
    anzahl = new int[n];
    this.uebergabe = uebergabe;
    }

    public AG3()
    {
    n = 4;
    mat = new double[n][n];
    }

    public double ausgabe()
    {
    return werte;
    }

    public boolean berechneGraphZusammenhaengend()
    {
    kanten();
    zusammenhaengend=true;
    for (int i = 0;i < n;i++)
    if (anzahl[i] == 0)
    zusammenhaengend=false;
    return zusammenhaengend;
    }

    public void kanten()
    {
    for(int i = 0;i < n;i++)
    {
    anzahl[i]=0;
    for(int j = 0;j < n;j++)
    if(Integer.parseInt(jt.getValueAt(i,j).toString()) > 0)
    anzahl[i]++;
    }
    }

    public void speichern() throws Exception
    {
    if(uebergabe == false)
    {
    for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
    {
    mat[i][j] = Double.parseDouble(jt.getValueAt(i,j).toString());
    if(i == j)
    mat2[i][j] = anzahl[i];
    }
    }
    else
    {
    for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
    {
    if(Double.parseDouble(jt.getValueAt(i,j).toString()) >= 1)
    mat[i][j] = 1;
    if(i == j)
    mat2[i][j] = anzahl[i];
    }
    }
    subtraktion();
    if(!berechneGraphZusammenhaengend())
    throw new Exception("Graph ist nicht zusammenhaengend!");
    nxN(mat);
    }

    public void subtraktion()
    {
    for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
    mat[i][j] = mat2[i][j] - mat[i][j];
    }

    public double nxN(double[][] matrix)
    {
    int n2 = matrix.length;
    double wert = 0;
    switch (n2)
    {
    case 3: wert = this.dreixDrei(matrix); break;
    default: wert = this.entwickeln(matrix); j++; break;
    }
    return wert;
    }

    public double dreixDrei(double[][] matrix)
    {
    double wert1 = matrix[0][0] * matrix[1][1] * matrix[2][2];
    double wert2 = matrix[0][1] * matrix[1][2] * matrix[2][0];
    double wert3 = matrix[0][2] * matrix[1][0] * matrix[2][1];
    double wert4 = matrix[0][2] * matrix[1][1] * matrix[2][0];
    double wert5 = matrix[0][0] * matrix[1][2] * matrix[2][1];
    double wert6 = matrix[0][1] * matrix[1][0] * matrix[2][2];
    double gesamt = wert1 + wert2 + wert3 -wert4 -wert5 -wert6;
    werte = Math.abs(gesamt);
    return gesamt;
    }

    public double entwickeln(double[][] matrix)
    {
    double wert = 0;
    double zw = this.nxN(this.unterMatrix(matrix, 0, l));
    wert += Math.pow(-1, 0+l) * matrix[0][l] * Math.abs(zw);
    System.out.println(wert + " " + matrix[0][l] + " " + Math.abs(zw) + " " + matrix.length);
    return wert;
    }

    public double[][] unterMatrix(double[][] matrix, int zeile, int spalte)
    {
    int n = matrix.length;
    double[][] umatrix = new double[n-1][n-1];
    int r = 0;
    int s = 0;
    for (int i=0; i<n; i++)
    {
    for (int k=0; k<n; k++)
    if (i != zeile && k != spalte)
    {
    umatrix[r][s] = (int) matrix[i][k];
    if (s+1 < n-1)
    s++;
    }
    if (i != zeile && r+1 < n-1)
    {
    s=0;
    r++;
    }
    }
    return umatrix;
    }
    }

  • Anzahl der Gerueste

    • JohannesSp
    • 3. Juni 2006 um 13:26

    Ich kann Java programmieren, nur leider nicht rekursiv und ich weiss nicht wie man die Anzahl der Gerüste berechnet.

  • Anzahl der Gerueste

    • JohannesSp
    • 3. Juni 2006 um 13:25

    Die Anzahl der Gerüste, benötige ich für die Graphentheorie.

  • Anzahl der Gerueste

    • JohannesSp
    • 3. Juni 2006 um 12:00

    Danke beefy, für die rasche Antwort. Leider verstehe ich den Code von der nicht. :confused:

    Wäre es möglich, dass du mir bitte den Code erklärst.

    MFG Joe

  • Anzahl der Gerueste

    • JohannesSp
    • 3. Juni 2006 um 10:48

    Hallo zusammen!

    Wir müssen in der Schule ein Programm in Java schreiben, dass die Anzahl der Gerueste berechnen kann.

    Nun meine Frage lautet, wie kann ich das am einfachsten berechnen?

    LG Joe

    PS. Ist sehr dringend.

Rechtliches

Impressum

Datenschutzerklärung