Just starting C++ Curious on what to learn for basic projects

This is what I need to learn by next may, plenty of time, but no idea where to start on these, I have some basic background of C++

2) [20 points] Simply Division

Sometimes, we just want to simplify a fraction, but the major programming languages do not
have this functionality built in. Instead, the division operator gives us a decimal. Write a
program that takes in a division, and instead of outputting the decimal, outputs a simplified
fraction. If the fraction would already be in simplest form, print the original fraction. If the
division is a whole number, let the denominator be 1.

Assumptions:
Numerator and denominator are always positive integers.

Input:
A fraction: two integers separated by the backslash symbol.

Output:
Output the division in simplest fractional form, e.g. “5/2”.

Sample Input: Sample Output:




Explanation:
There are 3 divisions, 1/5, 2/6, 8/4. Simplifying  1/5, 1/3, 2/1.





















1/5
2/6
8/4
1/5
1/3
2/1 Open Computer FAMAT State Convention 2014


3) [15 points] Scrambled Operators

Due to a system breakdown, the typical math operators (division, subtraction, addition, and
multiplication) have been scrambled. Division has now become addition, multiplication has
become subtraction, and vice versa. Write a program to evaluate expressions with these
scrambled operators.

Assumptions:
All numbers used as input are positive integers.

Input:
Integer followed by an operator (+, /, *, -) followed by another integer.

Output:
On a new line, print the result of the operation. Depending on your language, be careful of true
division!

Sample Input: Sample Output:





Explanation:
There are 4 operations to evaluate. + becomes division, / becomes addition, * becomes
subtraction, and – becomes multiplication.
1 + 2.0 becomes 1/2.0 = .5;
3 / 4 becomes 3 + 4 = 7;
5 * 6 becomes 5 – 6 = -1;
7 – 6 becomes 7 * 6 = 42.












1 + 2.0
3 / 4
5 * 6
7 - 6
.5
7
-1
42 Open Computer FAMAT State Convention 2014


4) [30 points] Bitty Ordering

A new way of ordering numbers has been devised, the bitty ordering. In this ordering scheme,
we first convert the numbers to base 2 and then order based on rightmost one. If multiple
numbers have the same rightmost one, then order based on the natural ordering in ascending
order. For example, given the numbers 1, 2, 3, we convert to 01, 10, 11. By following the bitty
ordering scheme, we would re-order the numbers to 01, 11, 10, or 1, 3, 2. Given a list of
numbers, order them by their bitty ordering.

Assumptions:
All numbers are non-negative integers.

Input:
A list of numbers to be sorted.

Output:
On one line, print out the ordering after implementing the bitty ordering scheme.

Sample Input: Sample Output:



Explanation:
There are 4 inputs: 1, 2, 3, 4. Their base 2 representation is as follows: 001, 010, 011, 100. The
two numbers with the rightmost one are 1 and 3. 1 < 3 so we first order 1, then 3.

2 has its rightmost one next, followed by 4. Thus we order 1, 3, 2, 4.













1, 2, 3, 4 1, 3, 2, 4 Open Computer FAMAT State Convention 2014


5) [35 points] Consecutivity

We define consecutivity as the “closeness” of a sorted list to a list of consecutive numbers. To
calculate consecutivity, we divide the total number of elements minus 1 by the sum of the
positive differences between consecutive elements. For example, the list [1, 2, 4] has
consecutivity 2/3.
2 – 1 = 1
4 – 2 = 2
Sum of positive differences between consecutive elements = 3
Total number of elements – 1 = 2
Consecutivity = 2/3

Given a list of unsorted numbers and a length x, find the sublist of length x that has the highest
consecutivity.

Assumptions:
Numbers input are integers. All numbers in the list are unique.

Input:
The first line specifies the number of integers given. The second line specifies the length of the
desired sublist. The following line is a list of numbers not necessarily in sorted order.

Output:
On the first line, print the full list of numbers. On the second line, print the value of the
consecutivity. If there are multiple equal lists, then print each list followed by its consecutivity.

Sample Input: Sample Output:







Explanation:
There are 6 integers in the list and we want to find the sublists of length 3 that give us the
highest consecutivity value. There are 4 such sublists: the consecutivity of each is 1.
We won;t write code for you, try starting it off yourself then post what you have and we can help. HINT: For the first question, you will have to use strings to display your fractions.
ok thanks, I have a whole year to learn this, I just want to have a better understanding of how to accomplish writing these programs
Write a program that takes in a division, and instead of outputting the decimal, outputs a simplified
fraction. If the fraction would already be in simplest form, print the original fraction. If the division is a whole number, let the denominator be 1.
This sounds like you need a Rational Number type.

Write a program to evaluate expressions with these scrambled operators.
Take a look at operator overloading.

A new way of ordering numbers has been devised, the bitty ordering.
Look at operator overloading, sorting and sort predicates.
Topic archived. No new replies allowed.