Operating System - Linux
1753276 Members
4784 Online
108792 Solutions
New Discussion юеВ

Need C++ code for this logic

 
Tnameh
Occasional Advisor

Need C++ code for this logic

Hello could someone help me in implementing a better logic in C++. I have a file Config,
To a program i wll pass
Record=3 Chance=4 it should display me all the 1ST 2ND 3RD record of chance1 , chance2, Chance3 Chance4.

It is assume that their wll be total 18 rows in each channel and max channel can be 5 . So in all(18.rows*5.channels) are there. And as shown below max Record can be 6 in each chance.

2nd Example
Record =2 and Chance =3
Should display record
1st 2nD of chance1, Chance2 ,Chance3

For Example 1
Since i have to avoid hard coding,what i have to do is , i wll read record
1st 2nd 3rd 4th of chance1 and skip all the remmaing records of chance1 .4th 5ht and 6th.

then again i wll put my pointer to 1st Record of Chance2 and wll repeat up
to record 4rd and skip remmaing record of chance 2

Repeat this upto chance4.





############################3
1ST:CHANCE1:
1ST:CHANCE1:
1ST:CHANCE1:
2ND:CHANCE1:
2ND:CHANCE1:
2ND:CHANCE1:
3RD:CHANCE1:
3RD:CHANCE1:
3RD:CHANCE1:
4TH:CHANCE1:
4TH:CHANCE1:
4TH:CHANCE1:
5TH:CHANCE1:
5TH:CHANCE1:
5TH:CHANCE1:
6TH:CHANCE1:
6TH:CHANCE1:
6TH:CHANCE1:
1ST:CHANCE2:
1ST:CHANCE2:
1ST:CHANCE2:
2ND:CHANCE2:
2ND:CHANCE2:
2ND:CHANCE2:
3RD:CHANCE2:
3RD:CHANCE2:
3RD:CHANCE2:
4TH:CHANCE2:
4TH:CHANCE2:
4TH:CHANCE2:
5TH:CHANCE2:
5TH:CHANCE2:
5TH:CHANCE2:
6TH:CHANCE2:
6TH:CHANCE2:
6TH:CHANCE2:
1ST:CHANCE3:
1ST:CHANCE3:
1ST:CHANCE3:
2ND:CHANCE3:
2ND:CHANCE3:
2ND:CHANCE3:
3RD:CHANCE3:
3RD:CHANCE3:
3RD:CHANCE3:
4TH:CHANCE3:
4TH:CHANCE3:
4TH:CHANCE3:
5TH:CHANCE3:
5TH:CHANCE3:
5TH:CHANCE3:
6TH:CHANCE3:
6TH:CHANCE3:
6ST:CHANCE3:
1ST:CHANCE4:
1ST:CHANCE4:
1ST:CHANCE4:
2ND:CHANCE4:
2ND:CHANCE4:
2ND:CHANCE4:
3RD:CHANCE4:
3RD:CHANCE4:
3RD:CHANCE4:
4TH:CHANCE4:
4TH:CHANCE4:
4TH:CHANCE4:
5TH:CHANCE4:
5TH:CHANCE4:
5TH:CHANCE4:
6TH:CHANCE4:
6TH:CHANCE4:
6TH:CHANCE4:
5 REPLIES 5
Tnameh
Occasional Advisor

Re: Need C++ code for this logic

Mistake here ,

It is assume that their wll be total 18 rows in each CHANCE and max channel(CHANCE) can be 5 . So in all(18.rows*5CHANCE) are there. And as shown below max Record can be 6 in each chance
NOT CHANNEL ,its CHANCE
Dennis Handly
Acclaimed Contributor

Re: Need C++ code for this logic

Is this the exact format of your config file? You actually use "1ST", instead of numbers?

Also is there a known order of records in the file or do you have to search for them?
Tnameh
Occasional Advisor

Re: Need C++ code for this logic

format remain the same, and its not 1 its 1st, 2nd 3rd... etc.......
Tnameh
Occasional Advisor

Re: Need C++ code for this logic

order is same as its shown, I dont have to search...
Order of records is 1st(3) 2nd(3row) 3rd(3rows) 4th(3rows)... 6th(3rows)
so 6*3 =18rows ==1 CHANCE.

Total CHANCE Max is 5 , 5*18 =90 rows
Dennis Handly
Acclaimed Contributor

Re: Need C++ code for this logic

Attached is a C program that has a triply nested for-loop. The inner loop always reads and prints 3 lines. The next loop reads or skips up to 6 groups of those 3. The outer loop just does Chance iterations.

The program ignores the contents of the records and assumes the format is 5 groups of 6 of 3 lines.

The trivial output is:
$ a.out Record=1 Chance=2
Doing 1, 2
1ST:CHANCE1:
1ST:CHANCE1:
1ST:CHANCE1:
1ST:CHANCE2:
1ST:CHANCE2:
1ST:CHANCE2: