Hello(repost)-

I am reposting because I didn't get the answer I needed. My teacher gave us this problem in a lab and I need help with it. Basically, he wants us to write an algorithm to count symbols. The user will provide anywhere between 3-10 symbols and then an initial number. For example:
user: 01234567, initial number: 106
output: 107, 110, 111, 112, 113, 114, 115, 116, 117, 120, 121.

user: abc, initial number: bb

output: bc, ca, cb, cc, aa, ab, ac, etc.

now after wracking my brain for the past 24 hours, i have thought to put the characters in a string, then have the initial number in another string. Then use a for loop, if statements to compare. If someone were to input "abcd" and an initial number of "bc" the output should look something like bc, ca, cb, cc, aa(startover), ab, ac, ba, bb, bc. Here is my code so far but does anyone have any good ideas for this(btw-I am a newbie at C++ so please be as specific as possible):

char symbol[10];
	char initial[5];
	cout<<"Input the symbols: "<<endl;
	cout<<"Input your initial number: "<<endl;
	cin>>symbol;
	cin>>initial;
	for(int i=3;i>-1;i--)
	{cout<<initial[i+1];}
	
	return 0;

user: 01234567, initial number: 106
output: 107, 110, 111, 112, 113, 114, 115, 116, 117, 120, 121.

I don't get it. How do you go from 106 to 107 then 110 etc. ? what is the relevance of 01234567?

Your question is too vague. For instance, is the sequence always going to linear as in your input sequence 01234567 or does the user have the ability to REALLY mix things up with an input like 90133854 ?
If not, then all you would need is the low starting number and the max number.

As you see there would be a great deal of difference in the two approaches.

Take a look in the <string> functions to find what you are looking for on the second issue.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Hello
I think I understand what you're trying to accomplish!
Looking at the frist example you presented: >01234567< is a sequence of numbers or what you call symbols.
+++++++++++++++
a b c d e f g h.
0 1 2 3 4 5 6 7.

Three numbers or symbols are chosen from that set. You call them initial.
The Initial gives you a starting point: 106.
+++++++++++++++
b a g
1 0 6

Your best code would be to connect the ends of the string. Seven needs connect back to Zero, like in a loop.

Maybe a linked-list or something like that.
This would allow you to loop through your symbols quickly and efficiently.

Below I used a nested FOR loop, "this code was not intended to work!",
but it maybe easier if you use algorithms and or templates.

for(x=0;x<s;x++){
                for(y=0;y<s;yx++){
                            for(z=0;z<s;zx++)
                                          {cout << x << y << z<< endl;   
                                  // x,y,z, is for loop assignment.
                                  //  x=MSB & z=LSB.
                                                                                        } //end z
                                                                                        } //end y
                                                                                        ) //end x

output
+++++++++++++++
107 bah
108 bai false why? no "i" or 8 therefore don't print.
109 baj also false: no "j" or 9
110 bba
111 bbb
112 bbc
113 bbd
114 bbe
115 bbf
116 bbg
117 bbh
118 bbi false no "i"
119 bbj false no "j"
120 bca
121 bcb
The loop stopped here, this matches your results so far.

Hope this is some help, let me know what you come up with to get it to work, I would be interested.

commented: Oh I get it now! Thanks :) +23
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.