Click here to Skip to main content
16,018,904 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Beginner question using headers Pin
Chris Losinger8-Nov-09 10:13
professionalChris Losinger8-Nov-09 10:13 
GeneralRe: Beginner question using headers Pin
LunaticFringe8-Nov-09 10:26
LunaticFringe8-Nov-09 10:26 
QuestionGet IExplorerBrowser from a Windows Explorer (Vista) Pin
Ivo Beltchev7-Nov-09 7:35
Ivo Beltchev7-Nov-09 7:35 
QuestionImage in word document Pin
arpanmukherjee17-Nov-09 4:28
arpanmukherjee17-Nov-09 4:28 
AnswerRe: Image in word document Pin
Maximilien7-Nov-09 5:24
Maximilien7-Nov-09 5:24 
GeneralRe: Image in word document Pin
arpanmukherjee17-Nov-09 23:35
arpanmukherjee17-Nov-09 23:35 
GeneralRe: Image in word document Pin
Rajesh R Subramanian8-Nov-09 19:57
professionalRajesh R Subramanian8-Nov-09 19:57 
QuestionHow to join two programes? Pin
Waldemar Ork7-Nov-09 3:33
Waldemar Ork7-Nov-09 3:33 
How to join two programes?
I’ve got two good fuctioning programs. The first one counts combinations with giving the elements of them. There are 180 elements in each combination. Here’s the code:
<code>#include "IndexCombination.h"
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &lt;algorithm&gt;
#include &lt;iterator&gt;
#include &lt;map&gt;
#include &lt;sstream&gt;
#include &lt;mem.h&gt;
#include &lt;conio.h&gt;
using namespace std;
using namespace stdcomb;
bool GetNextComb(std::vector&lt;unsigned int&gt; &amp;vi);
      struct Element
{
   char name[6];
   int numbers[30];
   char chain[90];
};
const Element elements[] = {
   {
         "ia11",
         {3,9,17,21,24,31,33,36,42,49,4,8,19,22,28,30,34,39,43,47,2,6,10,13,14,25,29,37,38,46},
         "3,9,17,21,24,31,33,36,42,49,4,8,19,22,28,30,34,39,43,47,2,6,10,13,14,25,29,37,38,46"
   }, {
         "ia34",
         {1,6,12,15,22,27,31,32,41,42,4,7,14,17,23,30,33,36,45,48,2,9,13,18,21,26,34,39,44,49},
         "1,6,12,15,22,27,31,32,41,42,4,7,14,17,23,30,33,36,45,48,2,9,13,18,21,26,34,39,44,49"
   }, {
         "ia72",
         {3,8,11,18,22,25,36,37,43,46,1,6,16,17,23,28,35,40,41,44,2,5,12,19,24,27,31,34,42,49},
         "3,8,11,18,22,25,36,37,43,46,1,6,16,17,23,28,35,40,41,44,2,5,12,19,24,27,31,34,42,49"
   }, {
         "ia167",
         {3,4,12,15,21,28,32,39,47,48,6,9,16,17,29,30,31,38,41,42,7,8,11,20,26,27,34,35,45,46},
         "3,4,12,15,21,28,32,39,47,48,6,9,16,17,29,30,31,38,41,42,7,8,11,20,26,27,34,35,45,46"
   }, {
         "ia190",
         {3,10,11,14,22,23,32,35,43,44,6,9,16,19,24,29,37,38,45,48,2,5,13,18,25,30,31,40,41,0},
         "3,10,11,14,22,23,32,35,43,44,6,9,16,19,24,29,37,38,45,48,2,5,13,18,25,30,31,40,41,0"
   }, {
         "ia21",
         {2,5,16,19,25,30,34,39,45,48,1,9,12,13,21,24,33,36,44,49,3,8,15,20,23,26,35,40,43,46},
         "2,5,16,19,25,30,34,39,45,48,1,9,12,13,21,24,33,36,44,49,3,8,15,20,23,26,35,40,43,46"
   }, {
         "ia64",
         {6,9,13,20,28,29,33,40,43,48,2,7,16,19,24,27,31,34,44,47,5,8,14,17,21,30,32,37,41,46},
         "6,9,13,20,28,29,33,40,43,48,2,7,16,19,24,27,31,34,44,47,5,8,14,17,21,30,32,37,41,46"
   }, {
         "ia102",
         {4,9,14,19,22,29,35,38,46,47,5,8,13,16,21,26,33,40,41,48,6,7,15,17,28,30,32,39,42,45},
         "4,9,14,19,22,29,35,38,46,47,5,8,13,16,21,26,33,40,41,48,6,7,15,17,28,30,32,39,42,45"
   }, {
         "ia178",
         {6,9,15,20,23,24,37,38,42,45,7,8,16,19,22,25,34,39,43,46,1,2,17,18,26,29,31,40,47,0},
         "6,9,15,20,23,24,37,38,42,45,7,8,16,19,22,25,34,39,43,46,1,2,17,18,26,29,31,40,47,0"
   }, {
         "ia180",
         {1,4,13,18,27,30,33,38,45,46,2,3,12,15,22,23,39,40,44,47,8,9,11,17,24,25,32,37,49,0},
         "1,4,13,18,27,30,33,38,45,46,2,3,12,15,22,23,39,40,44,47,8,9,11,17,24,25,32,37,49,0"
   }
};

int main(int argc, char *argv[])
{

   CIdxComb cb;
   cb.SetSizes(10,6);
     
   vector&lt;unsigned int&gt; combination(6);
   combination[0] = 0;
   combination[1] = 1;
   combination[2] = 2;
   combination[3] = 3;
   combination[4] = 4;
   combination[5] = 5;
   int Total = 0;
         do {        
                  Total++;
                  cout &lt;&lt; "Combination number. " &lt;&lt; Total   &lt;&lt; endl;
                  for (unsigned i = 0; i &lt; combination.size(); i++)
                        {
                                                           
                        const Element &amp;element = elements[combination[i]];
                        cout &lt;&lt; element.name &lt;&lt; ": " &lt;&lt; element.chain &lt;&lt; endl;
                        // tu musi być druga pętla for
                        }
               }
         while(cb.GetNextComb(combination));
     
      cout &lt;&lt; endl;
      system("PAUSE");
      return EXIT_SUCCESS;
}</code>The second program counts occurrances of the elements in given array and shows only those which values are equal or bigger than six.
#include &lt;iostream&gt;
#include &lt;mem.h&gt;
#include &lt;conio.h&gt;
using namespace std;
int main()
{
      int TestArray[] = {
3,10,11,14,22,23,32,35,43,      44,6,9,16,19,24,29,37,38,45,48,   2,5,13,18,25,30,31,40,41,0,
2,5,16,19,25,30,34,39,45,48,   1,9,12,13,21,24,33,36,44,49,      3,8,15,20,23,26,35,40,43,46,
6,9,13,20,28,29,33,40,43,48,   2,7,16,19,24,27,31,34,44,47,      5,8,14,17,21,30,32,37,41,46,
4,9,14,19,22,29,35,38,46,47,   5,8,13,16,21,26,33,40,41,48,      6,7,15,17,28,30,32,39,42,45,
6,9,15,20,23,24,37,38,42,45,   7,8,16,19,22,25,34,39,43,46,      1,2,17,18,26,29,31,40,47,0,
1,4,13,18,27,30,33,38,45,46,   2,3,12,15,22,23,39,40,44,47,      8,9,11,17,24,25,32,37,49,0};
   const int n = sizeof(TestArray) / sizeof(int);//combination.size();
   const int range = 100;
   const int minval = 6;
   int occurences[range];
   memset(occurences,0,range*sizeof(int));//combination.size();
   for (int i=0; i&lt;n; ++i)
      occurences[TestArray[i]]++;
   for (int i=0; i&lt;range; ++i)
      if (occurences[i]&gt;=minval)
         cout &lt;&lt; "number " &lt;&lt; i &lt;&lt; " occurs " &lt;&lt; occurences[i] &lt;&lt; " times\n";
   getch();
   return 0;
}

I’d like to join them in one program. The Output should look like this:
Combination number 1

Number 3 occurs 6 times
Number 48 occurs 7 times
Number 0 occurs 8 times

Combination number 2
Number 5 occurs 6 times

Etc.

What kind of counter or what loops should I use to successfully combine these programs?
AnswerRe: How to join two programes? Pin
LunaticFringe7-Nov-09 7:19
LunaticFringe7-Nov-09 7:19 
GeneralRe: How to join two programes? Pin
Waldemar Ork7-Nov-09 8:00
Waldemar Ork7-Nov-09 8:00 
GeneralRe: How to join two programes? Pin
LunaticFringe7-Nov-09 8:42
LunaticFringe7-Nov-09 8:42 
GeneralRe: How to join two programes? Pin
Waldemar Ork8-Nov-09 0:20
Waldemar Ork8-Nov-09 0:20 
GeneralRe: How to join two programes? Pin
Richard Andrew x648-Nov-09 6:55
professionalRichard Andrew x648-Nov-09 6:55 
GeneralRe: How to join two programes? Pin
LunaticFringe8-Nov-09 8:05
LunaticFringe8-Nov-09 8:05 
GeneralRe: How to join two programes? Pin
Waldemar Ork8-Nov-09 9:49
Waldemar Ork8-Nov-09 9:49 
QuestionRe: How to join two programes? Pin
David Crow7-Nov-09 10:06
David Crow7-Nov-09 10:06 
Questionneed information about online courses in vc++ Pin
l_d7-Nov-09 3:01
l_d7-Nov-09 3:01 
AnswerRe: need information about online courses in vc++ Pin
Richard MacCutchan7-Nov-09 4:23
mveRichard MacCutchan7-Nov-09 4:23 
Questiondraw buterfly grahics using c,c++ Pin
aviparida7-Nov-09 1:03
aviparida7-Nov-09 1:03 
AnswerRe: draw buterfly grahics using c,c++ Pin
Richard MacCutchan7-Nov-09 4:32
mveRichard MacCutchan7-Nov-09 4:32 
AnswerRe: draw buterfly grahics using c,c++ Pin
CPallini7-Nov-09 8:20
mveCPallini7-Nov-09 8:20 
QuestionHow to get Windows Handler from process id of excel instance. Pin
NarVish7-Nov-09 0:03
NarVish7-Nov-09 0:03 
AnswerRe: How to get Windows Handler from process id of excel instance. Pin
includeh107-Nov-09 1:01
includeh107-Nov-09 1:01 
GeneralRe: How to get Windows Handler from process id of excel instance. Pin
NarVish7-Nov-09 1:40
NarVish7-Nov-09 1:40 
GeneralRe: How to get Windows Handler from process id of excel instance. Pin
includeh107-Nov-09 2:06
includeh107-Nov-09 2:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.