NazerkeBS / Cplusplus

Programming course problem solutions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C++ problem solutions

  • Create a function which returns a random choice of head or tail.
  • Get a guess from the user and print if he/she has managed to hit the random generated choice.
  • Generate 1000 random choices. Determine the ratio of heads.
  • How many times was "heads" chosen exactly twice after each other? For example: THHHHTTHHTHHHTHH -> 2
  • How long was the longest sequence of heads?

The lottery.txt file contains the lottery results back to 1957. The first line of the file contains a number which gives the number of further lines. Each line contains the numbers of a week in ascending order. The following tasks have to be solved based on this input file:

  • Read 5 numbers from the user, all of them should be between 1 and 90. Check if all numbers are from this interval.
  • Print these numbers in ascending order.
  • Determine based on the input file which number was pulled most times.
  • Create a function which requires two vectors of length 5. The function should return how many elements of the two vectors match.
  • Based on the input file let's determine how many times the user has 1, 2, 3, 4 or 5 matches if he or she played every week.

lottery.txt: http://bruntib.web.elte.hu/english_cpp/lottery.txt

About

Programming course problem solutions.


Languages

Language:C++ 100.0%