-
Hi-lighting Or Similar
Given a 2D array which is initialised with the following numbers:
int list[3][8] = 1, 2, 3, 4, 5, 6, 7, 8;
9, 10, 11, 12, 13, 14, 15, 16;
17, 18, 19, 20, 21, 22, 23, 24;
a loop then iterates every combination and outputs:
1, 2, 3, 4, 5, 6, 7, 8
1, 2, 3, 4, 5, 6, 7, 16
1, 2, 3, 4, 5, 6, 7, 24
1, 2, 3, 4, 5, 6,15, 8
1, 2, 3, 4, 5, 6,15, 16
and so on......... ending with
17, 18, 19, 20, 21, 22, 23, 24.
Question is:-
I need to hi-light (or use someway) to be able to have 3 selected numbers
in the output. The selected numbers are: 1, 3, 5, 8, 9, 11, 13, 16, 17, 19, 21, 24
Any combination that has 3 of these numbers is to be outputted.
I am unable to find anything in C that will hi-light these numbers. Do I need to
learn visual basic, C#, does Dev-C++ have an option, or have I missed an algorithm in C that can do this? Thanx, Rossco
-
Which OS/Compiler are you using?
Yes you can highlight text on a console, but I know of at least 3 different ways (no, make that 4 different ways) of achieving it.
But there isn't a single way which is a guaranteed "works with every system".
-
I am using Dev-C++ compiler to all my work. As a beginner I haven't yet progressed to windows app. to do any work. Thus far I think this compiler with C coding will meet my needs. The more I think about it, an algorithm would be more efficient. I'm sure there's a mathematical genius here somewhere?
Here's a part of what I've accomplished thus far:-
Code:
int main()
{
int a, b, c, d, e, f, g, h, i, j;
i = 0;
int list[3][8];
list[0][0]= 1, list[0][1]= 2, list[0][2]= 3, list[0][3]= 4, list[0][4]= 5, list[0][5]= 6,
list[0][6]= 7, list[0][7]= 8;
list[1][0]= 9, list[1][1]=10, list[1][2]=11, list[1][3]=12, list[1][4]=13, list[1][5]=14,
list[1][6]=15, list[1][7]=16;
list[2][0]=17, list[2][1]=18, list[2][2]=19, list[2][3]=20, list[2][4]=21, list[2][5]=22,
list[2][6]=23, list[2][7]=24;
for(a=0; a<3; a++)
for(b=0; b<3; b++)
for(c=0; c<3; c++)
for(d=0; d<3; d++)
for(e=0; e<3; e++)
for(f=0; f<3; f++)
for(g=0; g<3; g++)
for(h=0; h<3; h++)
fprintf(fptr,"%4d%4d%4d%4d%4d%4d%4d%4d\n",list[a][0],list[b][1],list[c][2],list[d][3],
list[e][4],list[f][5],list[g][6],list[h][7]);
system ("PAUSE");
return 0;
}
so, the output needs to include 3 numbers (1,3,5,8,9,11,13,16,17,19,21,24) with the remainder of each line resulting in 5 other numbers listed.
This is a personal project, I have no aspirations of becoming a programmer.
Keep Well, Rossco.
-
-
Well! Giving this problem further consideration, I find it more prudent to focus on a C algorithm to include into the Fn rather than trying to learn a new application and language. If other languages have a function(Fn) that allows for hi-lighting, then that algorithm must be portable, even in part and usable in C.
Correct me if I'm wrong.... there must be a code in C somewhere that would allow for 3 of the numbers previously mentioned to be included into each line outputted?
-
You can format the output however you want with the standard output functions.
All you need to do is figure out which variables are involved.
-
I had a look at the site you suggested, code was in C++ tho' Thanx Salem. I'm still persevering, and revueing previous programs. There's a key somewhere near.