faecher:informatik:oberstufe:java:algorithmen:uebungen01:loesungsvorschlaege

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
faecher:informatik:oberstufe:java:algorithmen:uebungen01:loesungsvorschlaege [13.09.2021 12:39] – [A0] sbelfaecher:informatik:oberstufe:java:algorithmen:uebungen01:loesungsvorschlaege [18.03.2025 18:38] (aktuell) – [A01] Frank Schiebel
Zeile 8: Zeile 8:
 ++++ Lösungsvorschlag A01| ++++ Lösungsvorschlag A01|
 <code java> <code java>
-public int 01MyModulo(int a, int b)+public int Modulo(int a, int b)
     {     {
         int remainder=0;         int remainder=0;
Zeile 21: Zeile 21:
  
 <code java> <code java>
-public int MyModulo(int a, int b)+public int Modulo(int a, int b)
     {     {
         return a - a/b*b;         return a - a/b*b;
Zeile 242: Zeile 242:
  
  
-===== A0 =====+===== A12 =====
  
  
-++++ Lösungsvorschlag A0 |+++++ Lösungsvorschlag A12 |
 <code java> <code java>
 +public int a12zahlendreher(int zahl)
 +    {
 +        int stellenziffer=0;
 +        int stellenwert=1;
 +        int temp;
 +        int umgedreht=0;
  
 +        temp = zahl;
 +
 +        while (temp > 0) {
 +            temp = temp / 10;
 +            stellenwert = stellenwert * 10;
 +        }
 +
 +        stellenwert = stellenwert / 10; 
 +
 +        temp = zahl;
 +        while (temp > 0) { 
 +            stellenziffer = temp % 10;
 +            umgedreht = umgedreht + stellenziffer * stellenwert;
 +            stellenwert = stellenwert / 10;
 +            temp = temp / 10;
 +        }
 +
 +        return umgedreht;
 +    }
 </code> </code>
 ++++ ++++
  
-===== Lotto =====+===== A13 ===== 
 + 
 + 
 +++++ Lösungsvorschlag A13 | 
 +<code java> 
 + public double a13pi(int n, boolean watch) 
 +    { 
 +        double pi4=0.0; 
 +        double nenner=1.0; 
 +         
 +        for (int i=0; i<n; i++) { 
 +            if ( i % 2 == 0 ){ 
 +                pi4 = pi4 + 1.0/nenner;  
 +            } else { 
 +                pi4 = pi4 - 1.0/nenner;  
 +            } 
 +            nenner = nenner + 2;  
 +             
 +            if (watch) { 
 +                System.out.println("Iteration: " + i + "  Näherungswert: " + 4*pi4); 
 +            } 
 +        } 
 +         
 +        return 4*pi4; 
 +    } 
 +</code> 
 +++++ 
 + 
 +===== A14 ===== 
 + 
 + 
 +++++ Lösungsvorschlag A14 | 
 +<code java> 
 +public void a14quadrat(int n) 
 +    { 
 +        for (int i=0; i<n;i++) { 
 +            for(int j=0; j<n; j++) { 
 +                System.out.print("x "); 
 +            } 
 +            System.out.println(""); 
 +        } 
 +    } 
 +</code> 
 +++++ 
 + 
 +===== A15 ===== 
 + 
 + 
 +++++ Lösungsvorschlag A15 | 
 +<code java> 
 +public void a15dreieck(int n) 
 +    { 
 +        for (int i=0; i<=n;i++) { 
 +            for(int j=0; j<i; j++) { 
 +                System.out.print("x "); 
 +            } 
 +            System.out.println(""); 
 +        } 
 +    } 
 +</code> 
 +++++ 
 + 
 +===== A15 ===== 
 + 
 + 
 +++++ Lösungsvorschlag A | 
 +<code java> 
 + 
 +</code> 
 +++++ 
 +===== A16 =====
  
  
-++++ Lösungsvorschlag Lotto |+++++ Lösungsvorschlag A16 |
 <code java> <code java>
-public void a05lottozahlen () {+public void a16lottozahlen () {
                  
         int anzahl = 9;         int anzahl = 9;
  • faecher/informatik/oberstufe/java/algorithmen/uebungen01/loesungsvorschlaege.1631536756.txt.gz
  • Zuletzt geändert: 13.09.2021 12:39
  • von sbel