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, 01: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!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

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




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek