# Fundamentals of Computer Programming with C# HTML version

﻿
984 Fundamentals of Computer Programming with C#
techniques is to learn to approach the problem systematically and to
acquire the recipe for problem solving, we demonstrated earlier. Of course,
this is not enough, but it is a crucial step!
There is a recipe for programming-problem solving! Use a
systematical approach for better results, instead of your
sense. Even professionals, with more than 10 years of
experience, use the approach described in this chapter. Use
it yourself and you will be convinced that it works! Don’t
forget to test your solution seriously and deeply.
Finally we want to take a note on the cards shuffle algorithm. The “cards
shuffling” is well-known problem in computer science and there are classic
algorithms for solving it like the "Fisher-Yates Shuffle". Read more in
Exercises
1. Using the described in this chapter methodology of solving
programming problems, solve this problem: In a plane N points are
given (N < 100,000). The coordinates of the points are integers (xi, yi).
Write a program, which finds all horizontal and vertical lines, such
that they split the plane into two parts, each containing an equal set of
points (points lying on the line are note counted).
2. Using the described in this chapter methodology of solving programming
problems, solve this problem: A set S of n integers and a positive integer
k (k n 10) are given. An alternating sequence is a sequence, which
changes its behavior from ascending to descending and vice versa after
every element. Write a program, which generates all possible sequences
s1, s2, , sk containing k different elements from S.
Example: S = { 2, 5, 3, 4 }, K = 3: {2, 4, 3}, {2, 5, 3}, {2, 5, 4}, {3,
2, 4}, {3, 2, 5}, {3, 4, 2}, {3, 5, 2}, {3, 5, 4}, {4, 2, 3}, {4, 2, 5}, {4,
3, 5}, {4, 5, 2}, {4, 5, 3}, {5, 2, 3}, {5, 2, 4}, {5, 3, 4}.
3. Using the described methodology of creating solutions to programming
problems, solve the following problem: a map of a city is given. At this