Jump to content

Challenging algorithms!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
exonerated

exonerated

    Newbie

  • Members
  • Pip
  • 1 posts
Guys I need help with these exercises please if you can help me!

1. Flights. You have a table of flights that shows the flight number and the number of passengers.
You are only responsible for the flights with more than 100 passengers. To have a visualization
of the number of passengers you are responsible for, you want to print a star “*” for every 10
passengers (rounding up). Also print the flight number.
For example, if you have two flights, LH102 with 138 passengers and AZ399 with 101, the
output should look as the following:
LH102: **************
AZ399: ***********
Remember, you will not consider any flight that has 100 or less passengers.

2. Numbers. Write an algorithm that takes n numbers from the user and then prints the count
of positive numbers, the count of negative numbers and the count of zeros.

3. Average. Write an algorithm that takes n numbers and a threshold and then prints the average
of all numbers greater than the threshold (ignoring those numbers which are equal to or below
threshold).

#2
shawnhcorey

shawnhcorey

    Newbie

  • Members
  • Pip
  • 2 posts
What have you tried so far? Please show your code.

#3
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
*Sniff* *Sniff* Smells suspiciously like homework. We all know what that means...

While( !User.hasAnswer )
{
     User.askQuestion();

     if( User.postCode && User.putForthEffort )
     {
          CodeCallMembers.Help();
          User.hasAnswer = true;
     }
     else
     {
          CodeCallMembers.Laugh();
     }
}

-CDG10620
Software Developer

#4
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
lol ^^
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
No no, the challenging problems are at Project Euler
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog