Help with few questions in C++(Data Structure and templates)
Author |
Message |
Jinesh
|
Posted: Sun Oct 25, 2009 11:20 am Post subject: Help with few questions in C++(Data Structure and templates) |
|
|
1. Create a class with a vector of doubles as private. Write methods for the class that allow new numbers to be added, all copies of a specific number to be removed, the average of all the numbers to be calculated and the numbers to be displayed. Write a program that effectively tests your class.
2. Primes that are separated by two are called twin primes. For example, 3 and 5 are twin primes, as are 11 and 13. Write a program that stores in a vector and displays all twin primes up to a number specified by the user.
3. Write a program that repeatedly reads two numbers n and k and prints all bit patterns of length n with k ones in descending order (when the bit patterns are considered as binary numbers). You may assume that 30 >= n > 0, 8 > k >= 0, and n >= k. Leading zeroes in a bit pattern should be included. See the example below.
For example, the output patterns for n=2, k=1 are
10
01
And the output patterns for n=4, k=2 are
1100
1010
1001
0110
0101
0011
4. Write a program that inputs two positive integers less than five hundred written in Roman Numerals and outputs the sum in Roman Numerals. For example, given the input VII and II, the output is IX, and the input XXIX and X gives XXXIX. For Roman Numerals, the symbols I for 1, V for 5, X for 10, L for 50, C for 100, D for 500, and M for 1000 are used.
5. A positive integer is called nasty if it has at least two pairs of positive integer factors such that the difference of one pair equals the sum of the other pair.
For example, 6 is nasty since 6?1=6, 2?3=6, and 6?1=2+3; and 24 is also nasty since 12?2=6+4. Write a program which accepts as input a list of positive integers and determine if each one is nasty or not. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
wtd
|
Posted: Sun Oct 25, 2009 12:44 pm Post subject: RE:Help with few questions in C++(Data Structure and templates) |
|
|
How do you need help with this assignment? What do you have so far? |
|
|
|
|
|
|
|