Zum Inhalt springen

socressor

Mitglieder
  • Gesamte Inhalte

    4
  • Benutzer seit

  • Letzter Besuch

  1. Habe etwas probiert, aber vermute das es nicht richtig ist: Das sieht dann grafisch so aus:
  2. Danke abermals, aber ich meine programmatisch (PHP) Mein derzeitiger Stand: <html> <head> <title>Möp-Karte</title> <style type="text/css"> body { background: #000; color: #fff; } </style> </head> <body> <div align="center"> <h1>Möp-Karte</h1> <?php class map { function calc($from, $to) { $numeric=array($from => '', $to => ''); $letters=array($from => '', $to => ''); $splitter = str_split($from); $splitter2 = str_split($to); foreach($splitter as $fv){ if(is_numeric($fv)) { $numeric[$from]=$numeric[$from].$fv; }else{ $letters[$from]=$letters[$from].$fv; } } foreach($splitter2 as $tv){ if(is_numeric($tv)) { $numeric[$to]=$numeric[$to].$tv; }else{ $letters[$to]=$letters[$to].$tv; } } // var_dump($numeric); // var_dump($letters); //$this->view($numeric,$letters); //$this->view($from,$to); return array($numeric, $letters); } function x_axis($m=null, $n=null) { $data = array( "1" => "", "2" => "", "3" => "", "4" => "", "5" => "", "6" => "", "7" => "", "8" => "" ); if($m != null && $n != null) { $all = $this->calc($m, $n); //var_dump($all); foreach($all[0] as $signed) { if(stristr($m,$signed)) { $data[$signed] = $m; } if(stristr($n,$signed)) { $data[$signed] = $n; } } } return $data; } function y_axis($m=null, $n=null) { $data = array( "A" => "", "B" => "", "C" => "", "D" => "", "E" => "", "F" => "", "G" => "", "H" => "" ); if($m != null && $n != null) { $all = $this->calc($m, $n); //var_dump($all); foreach($all[1] as $signed) { if(stristr($m,$signed)) { $data[$signed] = $m; } if(stristr($n,$signed)) { $data[$signed] = $n; } } } return $data; } function view($from=null, $to=null) { $datax = $this->x_axis($from, $to); $datay = $this->y_axis($from, $to); //var_dump($datax); echo "<table style='border: 1px solid #fff; font-size: 40px; margin: 0 auto;' cellspacing='0'>"; foreach($datax as $keyx => $x) { echo "<tr style='border: 1px solid #fff;'>"; $datax[$keyx]=""; foreach($datay as $keyy => $y) { if($y == $keyy.$keyx) { echo "<td style='border: 1px solid red;'>".$keyy.$keyx."</td>"; } else { echo "<td style='border: 1px solid #fff;'>".$keyy.$keyx."</td>"; } } echo "</tr>"; } echo "</table>"; } } $mapClass = new map; ?> <table> <form method="POST" action=""> <tr><td>von:</td><td><input type="text" name="from" placeholder="From"></td></tr> <tr><td>zu:</td><td><input type="text" name="to" placeholder="To"></td></tr> <tr><td></td><td><input type="submit" value="Berechnen" name="calc"></td></tr> </form> </table> <?php if(isset($_POST['calc'])) { $mapClass->view($_POST['from'], $_POST['to']); }else{ $mapClass->view(); } ?> </div> </body> </html> [/PHP] Das sieht so aus und makiert derzeit Start und Ziel.
  3. hm vielen Dank, aber programmatisch bekomme ich das irgendwie nicht so hin.
  4. Hallo Leute, bin hier relativ neu und habe mal eine Frage an euch. Ich bin derzeit noch in der Ausbildung zum Fachinformatiker Fachrichtung Anwendungsentwicklung und habe eine kleine Aufgabe innerhalb des Betriebes bekommen. Nun bin ich noch relativ frisch dabei (PHP, etc) und finde den richtigen Algorithmus nicht. Vielleicht kann mir ja jemand helfen Aufgabenstellung: Erschaffe eine Karte (php) mit 8x8 quadratischen Feldern. Die Felder sollen über eine Buchstaben-Zahl Kombination ansprechbar sein. (Bis hierhin easy) Berechne nun Diagonal die Entfernung vom Mittelpunkt von Planquadrat C3 zu F7. Generalisiere die Methode, sodass du beliebige Felder nutzen kannst. Nächster Schritt: Die Bewegungen über Felder können nur an Kanten erfolgen. Diagonales ziehen ist daher nicht möglich. Finde einen Algorithmus, der einen Weg von B2 zu D3 findet. Generalisiere die Formel. Ich erwarte keine kompletten Lösungen von euch . Nur ein wenig Hilfestellung wäre nett . Möchte ja etwas dabei lernen. Mein derzeitige Code: class map { function calc($from, $to, $dia=null) { if($dia == true) { //Diagonal echo "true"; }elseif($dia == false) { //Nicht Diagonal echo "false"; } } function x_axis() { $data = array( "1" => "", "2" => "", "3" => "", "4" => "", "5" => "", "6" => "", "7" => "", "8" => "" ); return $data; } function y_axis() { $data = array( "A" => "", "B" => "", "C" => "", "D" => "", "E" => "", "F" => "", "G" => "", "H" => "" ); return $data; } function view() { $datax = $this->x_axis(); $datay = $this->y_axis(); echo "<table style='border: 1px solid #fff; font-size: 40px; margin: 0 auto;' cellspacing='0'>"; foreach($datax as $keyx => $x) { echo "<tr style='border: 1px solid #fff;'>"; foreach($datay as $keyy => $y) { echo "<td style='border: 1px solid #fff;'>".$keyy.$keyx."</td>"; } echo "</tr>"; } echo "</table>"; } } $mapClass = new map; $mapClass->view(); ?> <table> <form method="POST" action=""> <tr><td>von:</td><td><input type="text" name="from" placeholder="From"></td></tr> <tr><td>zu:</td><td><input type="text" name="to" placeholder="To"></td></tr> <tr><td>Diagonales ziehen:</td><td>Ja<input type="radio" name="dia" value="1">Nein<input type="radio" name="dia" value="0" checked></td></tr> <tr><td></td><td><input type="submit" value="Berechnen" name="calc"></td></tr> </form> </table> <?php if(isset($_POST['calc'])) { $mapClass->calc($_POST['from'], $_POST['to'], $_POST['dia']); } ?> [/PHP] Stecke also bei dem Algo für die Berechnung fest :confused:. Denke die Richtung ,,Satz des Pythagoras" wäre da richtig oder...

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...