PLEASE KINDLY HELP! AM SO CONFUSED

Pages: 12
Write your question here.

hi friends, please I need your help on how to write this program. am new here and I don't know where to start from.

here is the question:

Given a set A,B,C,D,E........W. Write C++ program that will generate 5 unrepeatableĀ  subset with AB being constant.


I learnt the 5 unrepeatable subset that will be generated will be 1330 in number.

the output will look like this: ABCDE, ABCDF, ABCDG till the end. in all of these, AB will remain constant.

I will appreciate your kind help. Thanks

high regards
Michael

Last edited on
somebody should please help me out. it's urgent
People will be more willing to help if you actually try it yourself, and then maybe post some of your code that isn't working.

At the moment it just looks like you're waiting for someone to come along and do your homework for you.
@enemy, at what point in the OP's question will he want to call rand()? There is no requirement for anything to be randomly generated.
try to do: if generated number is in range from...to, then print c or d etc
Last edited on
1
2
3
4
5
6
7
// Example program
#include <iostream>

int main ()
{
	std::cout << int('C') << " " << int('W'); // 67 87
}


so you need 3 non-repeated random value from 67 to 87.

EDIT:
example process:
set1: AB, C(67) W(87) W(87)
set2: AB, C P M (ok after comparing previous sets)
set2: AB, C W W (woops. it has been equal to a previous set, so it should be re-calculated.)
Last edited on
Dont mean to be a pain, but i think the question isn't too refined.

Does that mean "unrepeatable" or "unrepeated"?

do you have to start "AB" or can the AB be anywhere?

I see it says 5 subsets, where does it say that the subsets have to be length 5? or even all the same length?


@anup
surely 3 non repeated values would stop the W appearing twice in the same sequence?

> surely 3 non repeated values would stop the W appearing twice in the same sequence?

don't know if repetition is allowed inside a "word" , OP can clear it.
mikeisang wrote:
I learnt the 5 unrepeatable subset that will be generated will be 1330 in number.


There are 21 letters from C to W. The total number of 3 letter sequences with non-repeating letters would be 21 * 20 * 19 = 7980, which is much larger than 1330.

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>

int main()
{
    int counter = 0;
    for (int i = 0; i < 19; ++i)
        for (int j = i + 1; j < 20; ++j)
            for (int k = j + 1; k < 21; ++k)
                ++counter;
    std::cout << counter;
}
1330

Therefore, OP wants sequences where each successive letter comes after the letter before it in the alphabet.

set1: AB, C(67) W(87) W(87) (not OK, W does not come after W)
set2: AB, C P M (not OK, M does not come after P)
set3: AB, C P W (OK)

Combinations vs Permutations
Last edited on
>
There are 21 letters from C to W. The total number of 3 letter sequences with non-repeating letters would be 21 * 20 * 19 = 7980, which is much larger than 1330.

>
set1: AB, C(67) W(87) W(87) (not OK, W does not come after W)
set2: AB, C P M (not OK, M does not come after P)
set3: AB, C P W (OK)


if you do by "come after" method, total set wont be 7980.
anup30 wrote:
if you do by "come after" method, total set wont be 7980.

Right, there would be 1330 total sets.

mikeisang wrote:
I learnt the 5 unrepeatable subset that will be generated will be 1330 in number.
> Right, there would be 1330 total sets.

yes, we can get that by programming.
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>

int main(){
	int sum=0;
	
	for(int i=1; i<=19; i++){
		sum += i*(20-i);
	}
	
	std::cout<< sum; // 1330
}

a big thank you to fg10g and anup30 and every other person that contributed here. here is an hint to further help you guys understand what I really want:


The set generated must start with AB at every point, this means AB is constant. apart from AB, every other set generated must not have repeated letters and this must iterate till the letter W.

An output of it will look like this:
ABCDE
ABCDF
ABCDG
ABCDH
ABCDI
ABCDJ
ABCDK
ABCDL
ABCDM
ABCDN
ABCDO
ABCDP
SBCDQ
ABCDR
ABCDS
ABCDT
ABCDU
ABCDV
ABCDW

AND SO ON AND SO FORTH TILL THE last set is generated.

I will like to see the final output pasted here. let's use char so that it will take care of the generated set. also show us the code. expecting your response soonest.

you have to also prompt for the letters A -W to be captured from the keyboard and also print the entire output (un-repeated) sets generated at the end. thanks

high regards
mikeisang
Last edited on
What have you done so far?
but you saw the sets I generated above. I need the code to generate the rest of the outputs. thanks. please help if you know the coding. am here to learn. of course you've been resourceful here, pls kindly give me your best answer with respect to the explanations I gave above.
That only shows your understanding of the problem. You're supposed to write the code for it. You're asking people to solve it for you without showing any code proving you have attempted to do it on your own.

At any rate, I practically gave you a solution in my first post. Maybe this would be easier to understand:

1
2
3
4
5
6
7
8
9
#include <iostream>

int main()
{
    for (int i = 3; i < 22; ++i)
        for (int j = i + 1; j < 23; ++j)
            for (int k = j + 1; k < 24; ++k)
                std::cout << "1, 2, " << i << ", " << j << ", " << k << '\n';
}
A big thank you to fg109. Am highly indebted to you. high regards
Last edited on
#include <iostream>
int main()
{
for ( char i = C; i < V; ++C)
for ( char j = ++C; j < W; ++D)
for ( char k = ++D; k < X; ++E)
std::cout << "A, B, " << i << ", " << j << ", " << k << '\n' ;
}


I attempted running this but had so many errors. I actually want to generate the output in char format and not in integer format. final help from you pls, thanks
do you need to print all 1330 numbers? or randomly any 5 of them.
Pages: 12