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
Reply

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


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




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

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




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
Stay green...Green IT