Click here to Skip to main content
15,884,176 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Regarding Dictionary Application Pin
Alan Balkany5-Oct-09 4:25
Alan Balkany5-Oct-09 4:25 
QuestionIs there a sample for using ActiveX without registering it? Pin
transoft2-Oct-09 5:03
transoft2-Oct-09 5:03 
AnswerRe: Is there a sample for using ActiveX without registering it? Pin
includeh102-Oct-09 6:02
includeh102-Oct-09 6:02 
GeneralRe: Is there a sample for using ActiveX without registering it? Pin
Code-o-mat2-Oct-09 6:16
Code-o-mat2-Oct-09 6:16 
GeneralRe: Is there a sample for using ActiveX without registering it? Pin
CPallini2-Oct-09 9:09
mveCPallini2-Oct-09 9:09 
GeneralRe: Is there a sample for using ActiveX without registering it? Pin
PJ Arends2-Oct-09 10:06
professionalPJ Arends2-Oct-09 10:06 
GeneralRe: Is there a sample for using ActiveX without registering it? Pin
Nemanja Trifunovic2-Oct-09 10:25
Nemanja Trifunovic2-Oct-09 10:25 
QuestionHow to count repeating elements in an array ? Pin
Waldemar Ork2-Oct-09 4:44
Waldemar Ork2-Oct-09 4:44 
Hi guys,
I've just written a piece of code which works fine and now I need to do one more and the last operation to complete the whole project. I'd like to count how many times all elements in each combination repeat. To be more precise I'm   interested in number of occurences which are equal or bigger than six. Here's the code. You can use it for your studies if you want:

#include "IndexCombination.h"
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <map>
#include <sstream>
using namespace std;
using namespace stdcomb;

bool GetNextComb(std::vector<unsigned int> &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<unsigned int> combination(6);
   combination[0] = 0;
   combination[1] = 1;
   combination[2] = 2;
   combination[3] = 3;
   combination[4] = 4;
   combination[5] = 5;

   int Total = 0;
     
   while(cb.GetNextComb(combination))//the compiler stops here
   {
         Total++;
         cout << "Combination number. " << Total << endl;

         for (unsigned i = 0; i < combination.size(); i++)
         {
            const Element &element = elements[combination[i]];
            cout << element.name << ": " << element.chain << endl;


         }
         cout << endl;
   }
      system("PAUSE");
      return EXIT_SUCCESS;
}

I know that only a few lines are needed to achieve the goal. I've read quite a lot on the subject, but somehow can't figure out how to do it.
Can anybody help me ?
QuestionRe: How to count repeating elements in an array ? Pin
David Crow2-Oct-09 8:44
David Crow2-Oct-09 8:44 
AnswerRe: How to count repeating elements in an array ? Pin
Waldemar Ork2-Oct-09 10:44
Waldemar Ork2-Oct-09 10:44 
QuestionTimeOut recieved while trying to take snapshot using VSS Pin
Vishuk2-Oct-09 4:36
Vishuk2-Oct-09 4:36 
GeneralDDX_CONTROL in lieu of ::Create for Cricheditctrl Pin
ForNow2-Oct-09 3:42
ForNow2-Oct-09 3:42 
GeneralRe: DDX_CONTROL in lieu of ::Create for Cricheditctrl Pin
Code-o-mat2-Oct-09 6:10
Code-o-mat2-Oct-09 6:10 
GeneralRe: DDX_CONTROL in lieu of ::Create for Cricheditctrl Pin
ForNow2-Oct-09 7:09
ForNow2-Oct-09 7:09 
GeneralRe: DDX_CONTROL in lieu of ::Create for Cricheditctrl Pin
Code-o-mat2-Oct-09 9:18
Code-o-mat2-Oct-09 9:18 
GeneralRe: DDX_CONTROL in lieu of ::Create for Cricheditctrl Pin
ForNow2-Oct-09 11:52
ForNow2-Oct-09 11:52 
GeneralRe: DDX_CONTROL in lieu of ::Create for Cricheditctrl Pin
Code-o-mat2-Oct-09 23:38
Code-o-mat2-Oct-09 23:38 
GeneralRe: DDX_CONTROL in lieu of ::Create for Cricheditctrl Pin
ForNow4-Oct-09 14:12
ForNow4-Oct-09 14:12 
GeneralRe: DDX_CONTROL in lieu of ::Create for Cricheditctrl Pin
Code-o-mat4-Oct-09 20:24
Code-o-mat4-Oct-09 20:24 
GeneralRe: DDX_CONTROL in lieu of ::Create for Cricheditctrl Pin
ForNow5-Oct-09 0:49
ForNow5-Oct-09 0:49 
QuestionWINDOWS.H already included. MFC apps must not #include <windows.h></windows.h> Pin
dehseth2-Oct-09 3:39
dehseth2-Oct-09 3:39 
AnswerRe: WINDOWS.H already included. MFC apps must not #include Pin
«_Superman_»2-Oct-09 4:13
professional«_Superman_»2-Oct-09 4:13 
AnswerRe: WINDOWS.H already included. MFC apps must not #include Pin
Rajesh R Subramanian2-Oct-09 20:46
professionalRajesh R Subramanian2-Oct-09 20:46 
QuestionMFC CreateEx function crashes program Pin
ChrisBuckley2-Oct-09 3:23
ChrisBuckley2-Oct-09 3:23 
AnswerRe: MFC CreateEx function crashes program Pin
Cedric Moonen2-Oct-09 3:48
Cedric Moonen2-Oct-09 3:48 

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.