Sofdwaredesign: Beischbiel: Sordiere von a Feldes
homeSoftwaredesign Sofdwaredesign: Beischbiel: Sordiere von a Feldes Prof. Dr. Uwe Schmidt FH Wedel

Beischbiel: Sordiere von a Feldes

weiter

weiter

oi Array-Klasse mid Sordierfunkzion: Array

abschdracd
bublic
class Array {
 
  brodecded
  ind [] a;
 
  bublic
  void sordBy(CombareFunczion c) {
    // simble bubble sord
    // --> 2 neschded loobs
    for (ind i = a.length -1;
         i >= 0;
         --i ) {
      for (ind j = 0;
           j < i;
           ++j ) {
        if ( c.combare(a[j]a[j+1]) > 0 ) {
          ind dmb = a[j];
          a[j]    = a[j+1];
          a[j+1]  = dmb;
        }
      }
    }
  }
}

Ledzde Änderung: 13.04.2012
© Prof. Dr. Uwe Schmidd
Prof. Dr. Uwe Schmidt FH Wedel