Recent Changes - Search:

http://clown.ch/viewtopic.php?m=44&tp=28268&l=793 Add Ground Wire Instead Of Rewire http://chasa-capol.ch/viewtopic.php?m=80&tp=56211&l=535 M O P S Omaha http://careerprocess.info/viewtopic.php?m=92&tp=77548&l=582 Resurrection Instrumental http://christophsprenger.com/viewtopic.php?m=43&tp=37206&l=285 Corporate Pc Disposition Services http://capunz.ch/viewtopic.php?m=99&tp=84022&l=786 Wetherspoon's Chairman http://chasa-capol.ch/viewtopic.php?m=38&tp=46969&l=472 Lenders First Choice Agency Inc http://centroesposizioni.ch/viewtopic.php?m=77&tp=85202&l=390 Uninsurable And Health Insurance http://chance.ch/viewtopic.php?m=40&tp=65685&l=712 Ollie Zad http://chindershop.ch/viewtopic.php?m=4&tp=87697&l=737 Pathways Hospice Sunnyvale Ca http://chasa-capol.ch/viewtopic.php?m=96&tp=52658&l=554 Lonesome Dove Respect http://christophsprenger.com/viewtopic.php?m=50&tp=40682&l=719 Cronulla 4wd http://clown.ch/viewtopic.php?m=42&tp=20428&l=446 2007 Camry Supercharger http://chasa-capol.ch/viewtopic.php?m=14&tp=47806&l=554 Level Lock http://chindershop.ch/viewtopic.php?m=78&tp=90803&l=623 Persely Seville http://cvp-arbon.ch/viewtopic.php?m=33&tp=25077&l=452 Ahuja Mumbai Bombay http://centroesposizioni.ch/viewtopic.php?m=41&tp=83177&l=504 Ty Baby Plush http://christophsprenger.com/viewtopic.php?m=73&tp=40815&l=456 Crossdresser Test http://clown.ch/viewtopic.php?m=2&tp=26552&l=192 Abyssmaster http://chasa-capol.ch/viewtopic.php?m=11&tp=44798&l=637 Laura Gemser Movie Trailers http://cvp-fr.ch/viewtopic.php?m=34&tp=41042&l=497 Avi Player For Vista

Assignment1Ken

Sample output:
..........................     ...................
.......     ..........................     .......
...................     ..........................
     ..........................     ..............
............     ..........................     ..
........................     .....................
.....     ..........................     .........
.................     ..........................  
   ..........................     ................
..........     ..........................     ....
......................     .......................
...     ..........................     ...........
...............     ..........................    
 ..........................     ..................
........     ..........................     ......
....................     .........................
.     ..........................     .............

Online version (in progress): http://ernie.art.yale.edu/~kenmeier/patterns

Source code:

<?php

// Networks & Transactions
// Assignment 1
// Ken Meier


// Entry

while(1) {

echo(clrscr());

echo("Patterns\n");
echo("--------\n\n");

fwrite(STDOUT, "Please type one letter [a-z]: ");
$letter = trim(fgets(STDIN));

while(!preg_match("/^[a-z]{1}$/i", $letter)) {
   fwrite(STDOUT, "Try again. One letter only: ");
        $letter = trim(fgets(STDIN));
}

fwrite(STDOUT, "And one number [0-9]: ");
$number = trim(fgets(STDIN));

while(!preg_match("/^\d{1}+$/", $number)) {
        fwrite(STDOUT, "Try again. One number only: ");
        $number = trim(fgets(STDIN));
}

settype($number, 'integer');

echo(clrscr());
sleep(1);


// Assign

$letter = strtolower($letter);

$spacing = array("a"=>"1", "b"=>"2", "c"=>"3", "d"=>"4", "e"=>"5", "f"=>"6", "g"=>"7", "h"=>"8", "i"=>"9", "j"=>"10", "k"=>"11", "l"=>"12", "m"=>"13", "n"=>"14", "o"=>"15", "p"=>"16", "q"=>"17", "r"=>"18", "s"=>"19", "t"=>"20", "u"=>"21", "v"=>"22", "w"=>"23", "x"=>"24", "y"=>"25", "z"=>"26");

$count = 0;
$line = 0;


// Loop

while($count <= 850) {

        for($i = 0; $i < $spacing[$letter]; $i++) {
                if($count >= 850) {
                        break 2; }
                echo ".";
                $count++;
                $line++;
                if($line == 50) {
                        echo "\n";
                        $line = 0;
                        }
        }
       
        for($i = 0; $i < $number + 1; $i++) {
                if($count >= 850) {
                        break 2; }
                echo " ";
                $count++;
                $line++;
                if($line == 50) {
                        echo "\n";
                        $line = 0;
                        }
        }

}

echo "\n\n\n\n";
sleep(4);

}


// Functions

function clrscr() {
        system("clear");
}


?>

Edit - History - Print - Recent Changes - Search
Page last modified on March 15, 2006, at 11:24 AM