General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 1st, 2009, 02:03 PM
pmcmahon pmcmahon is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 1 pmcmahon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 43 sec
Reputation Power: 0
Wallpaper algorithm (absolute beginner pascal)

Hi
I'm just getting into the world of computer science and programming. In preparation for applying to university, I'm reading the New Turing Omnibus -it's on the recommended undergraduate reading list so I thought I'd give it a go. The first chapter is on algorithm's -taking the standard route of comparing a recipe to a program (I say standard because I've seen it in various other tutorials) the chapter then goes on to discuss a simple 'wallpaper' algorithm that essentially makes pretty patterns. It's an exercise designed to demonstrate the power of a simple algorithm.

Anyway out of interest I was trying to replicate this program. In the book it shows the program written in pascal so I downloaded a pascal compiler and tried to compile/run the program. There were various errors and, and I don't know if I was doing the right thing in the first place. So here I am!

Here's the basic program:
1. input corna, cornb
2. input side
3. for i <-- 1 to 100
1. for j <-- 10 to 100
x <-- corna + i * side/100
y <-- cornb + j * side/100
c <-- int (x^2 + y^2)
if c even
then plot (i, j)

And here's the program in pascal:

program WALLPAPER (input, output) ;
var corna, cornb, side, x, y, c: real;
var i, j: integer;
begin
read (corna, cornb);
read (side);
graphmode ;
for i: = 1 to 100 do
begin
for j:= 1 to 100 do
begin
x: = corna + i*side/100;
y: = conb + j*side/100;
c: = trunc(x*x + y*y);
if cmod2 = 0 then graph.putpixel (i, j, 1);
end
end
[INDENT]textmode;
end

I hope that comes out ok - my html is awful...
I did understand the chapter, and I've done a small amount of python programming in the past. Basically my query is how can I implement this program? Is it simply a case of writing it up into the compiler or does more need to be done. The limit of my python programming was a program that wrote out all the times tables, which was just a case of hitting enter to run it. Since this is graphical maybe more needs to be done?

I don't think this is the kind of question you regularly get here, hopefully you won't mind helping me out!

Thanks in advance
phil

Reply With Quote
  #2  
Old January 11th, 2011, 09:09 AM
relpGlups relpGlups is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Location: Ghana
Posts: 1 relpGlups User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 25 sec
Reputation Power: 0
Send a message via ICQ to relpGlups
im here

fuking love this forum

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Wallpaper algorithm (absolute beginner pascal)


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap