Jump to content

My Pascal problem. Help ASAP! D:

- - - - -

  • Please log in to reply
8 replies to this topic

#1
happiness

happiness

    Newbie

  • Members
  • Pip
  • 7 posts
The king of Fancyland has bought a piece of land that's in an area which is made from pieces of square shape. The price of the land if being measured by the number of the whole square-shaped pieces [fields] which are on the parcel. Due to this, it's easier to calculate the price of the parcel in Fancyland than in Yukiland. [that’s another random country in the task]. Your task is to write a program which will calculate the price of the parcel which is bought. Pieces of the field which make [form] the parcel form a closed polygon which apexes are corners of square fields. For example, polygon from the picture [which fits the first from the three examples] contains three square fields [square-shaped fields, so its value [price] is 3.

Input
In the first line of standard input is a whole number N [whole number is 3,4,5 and so, not 0,75 or 1/4 and so]
(3<=N<=100). N is the number of apexes of the polygon. In every line of the following N lines there are couples of whole numbers Xi and Yi, coordinates of i-th apex of the polygon. The apexes are given in order in which they appear in the perimeter of the polygon. You can suppose that there won't be coordinates lesser than [under] -500 or bigger [above] 500 and that the polygon will be convex. [because the law in Fancyland says so]

OUTPUT

The output has to contain only one line in which there is one whole number [the price (value) of the parcel (piece of land) that is bought. The price equals the number of whole square-shaped fields in it.

Input

4
1 1
5 3
5 4
3 5
Output:
3


Input
5
3 3
2 5
3 4
5 2
4 2

Output:
0

Input:
5
0 0
0 -50
-50 -51
-51 -50
-50 0

Output:
2500

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
It looks like this is homework. Given that, what part are you having difficulties with? What have you coded so far?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
happiness

happiness

    Newbie

  • Members
  • Pip
  • 7 posts
Nothing, really nothing. I have to solve this, and another 4 tasks till 8 pm [Central European time] or I will probably fail a grade of something like that. But I haven't studied anything and now I'm begging for anyone to help me! D: Practically, I'm looking for anyone who would be so kind to write those few programs for me, and in return I'll be grateful forever.

#4
happiness

happiness

    Newbie

  • Members
  • Pip
  • 7 posts
And I can solve the problems in C or C++ too...

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
We don't do people's homework for them. We help people do their own homework.

With that said: First you have to be able to open the file to read the input. The first line is an integer, each additional line goes into an array of x's and y's.

Have you grabbed a piece of paper to plot out the coordinates that are inputted? Your output is NOT the area of the polygon, it is the number of 1x1 squares that are located entirely within the polygon. See this example of the first input.[ATTACH=CONFIG]3703[/ATTACH]
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#6
happiness

happiness

    Newbie

  • Members
  • Pip
  • 7 posts
We haven't even studied arrays at school.

#7
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
What have you studied?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#8
happiness

happiness

    Newbie

  • Members
  • Pip
  • 7 posts
Only linear type of tasks.

#9
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
You need to know how to use loops, file access, and arrays. If you haven't studied those, there is something VERY wrong with this assignment.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users