WN

WN (https://www.wn.se/forum/index.php)
-   Allmänt (https://www.wn.se/forum/forumdisplay.php?f=2)
-   -   Matematiskt tips på ett länkschema sökes. (https://www.wn.se/forum/showthread.php?t=1055065)

Conny Westh 2012-09-21 23:04

Här är samma kod översatt till PHP:

Kod:

<?php
// Program i PHP
// Author: Conny Westh

        class Program
        {
                function Main()
                {
                        $rlink = new RefLink();
                        $antalWebbPlatser = 21;
                        $antalVeckor = 7;

                        for ($webbPlats = 1; $webbPlats <= $antalWebbPlatser; $webbPlats++)
                        {
                                for ($vecka = 1; $vecka <= $antalVeckor; $vecka++)
                                {
                                        $rlink->visa($webbPlats, $vecka, $antalWebbPlatser, $antalVeckor);
                                }
                                echo "\n";
                        }
                        //Console.ReadKey();
                }
        }

        class RefLink
        {
                function visa($AktuellWebbPlats, $aktuellVecka, $antalWebbPlatser, $antalVeckor)
                {
                        echo "Webbplats: " . $AktuellWebbPlats . ", Vecka: " . $aktuellVecka . ", Visar länk för: ";
                        for ($webbPlats = 0; $webbPlats < $antalWebbPlatser; $webbPlats++)
                        {
                                if ((($webbPlats + 1) != $AktuellWebbPlats) && (((($aktuellVecka - 1 + $webbPlats + $AktuellWebbPlats) % $antalVeckor)) == 0))
                                {
                                        echo " - " . ($webbPlats + 1) ;
                                }
                        }
                        echo "\n";
                }
        }

$r = new Program();

$r->Main();


?>


kingkong 2012-09-25 08:38

Härligt Conny!! Funkade kanon i PHP. Tack! Du verkar tänka i koder. :D

Jag skickar ett PM till dig.


Alla tider är GMT +2. Klockan är nu 09:40.

Programvara från: vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Svensk översättning av: Anders Pettersson