Click here to Skip to main content
15,911,360 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Passing an array as argument to a function (2) Pin
Victor Nijegorodov28-Apr-20 10:22
Victor Nijegorodov28-Apr-20 10:22 
GeneralRe: Passing an array as argument to a function (2) Pin
Calin Negru28-Apr-20 10:45
Calin Negru28-Apr-20 10:45 
GeneralRe: Passing an array as argument to a function (2) Pin
Victor Nijegorodov28-Apr-20 10:58
Victor Nijegorodov28-Apr-20 10:58 
GeneralRe: Passing an array as argument to a function (2) Pin
Calin Negru28-Apr-20 20:59
Calin Negru28-Apr-20 20:59 
GeneralRe: Passing an array as argument to a function (2) Pin
Victor Nijegorodov30-Apr-20 6:13
Victor Nijegorodov30-Apr-20 6:13 
GeneralRe: Passing an array as argument to a function (2) Pin
Calin Negru1-May-20 0:51
Calin Negru1-May-20 0:51 
QuestionParsing the Command Line Pin
Richard Andrew x6426-Apr-20 5:50
professionalRichard Andrew x6426-Apr-20 5:50 
QuestionRe: Parsing the Command Line Pin
David Crow27-Apr-20 1:59
David Crow27-Apr-20 1:59 
AnswerRe: Parsing the Command Line Pin
Richard Andrew x6427-Apr-20 2:03
professionalRichard Andrew x6427-Apr-20 2:03 
AnswerRe: Parsing the Command Line Pin
David Crow27-Apr-20 2:12
David Crow27-Apr-20 2:12 
GeneralRe: Parsing the Command Line Pin
Richard Andrew x6427-Apr-20 3:00
professionalRichard Andrew x6427-Apr-20 3:00 
SuggestionRe: Parsing the Command Line Pin
David Crow27-Apr-20 3:31
David Crow27-Apr-20 3:31 
AnswerRe: Parsing the Command Line Pin
Graham Breach27-Apr-20 4:34
Graham Breach27-Apr-20 4:34 
GeneralRe: Parsing the Command Line Pin
Richard Andrew x6427-Apr-20 5:13
professionalRichard Andrew x6427-Apr-20 5:13 
PraiseRe: Parsing the Command Line Pin
David Crow27-Apr-20 7:16
David Crow27-Apr-20 7:16 
QuestionHow to count occurences of a number and its most frequent pair in a text file? Pin
kangkongflea25-Apr-20 0:31
kangkongflea25-Apr-20 0:31 
Supposed I have a text file having the results of the 6/49 lottery in it:
49-05-13-42-18-45
43-24-36-16-39-22
32-48-05-18-34-29
13-14-07-41-48-39
47-05-17-13-37-49
06-23-34-21-46-37
06-42-13-40-11-37
39-44-40-21-32-20
17-26-38-43-01-02

How can I achieve the following output written to a text file with filename, "occurences.txt"?
49 - 2 times
49 paired with 13 - 2 times

I don't have an exact idea but maybe the following pseudocode can help:

C++
void main ()
{
 int number
 
 cout<<"CHARACTER \t\ How many times it appeared"<<endl;

 for (number='01'; number<='49'; number++)
 {
  cout<<number<<" - \t"<<countNumber(numbercount)<<" times"<<endl;
  cout<<number<<" paired with \t"<<number<<" "<<ountNumber(numbercount)<<" times"<<endl;
 }

 
 system ("PAUSE");
 return 0;
}

int countNumbers (int number)
{
 ifstrem.stream; //to open the file
 int numbercount;
 int count=0; //counter to count occurences

 stream.open ("countNumbers.txt"); //this opens the file
 stream.get (numbercount);

 while (!stream.fail())
 {
  if (numbercount==number)
    count++
    stream.get(numbercount);
 }

stream.close ();

return numbercount;
}



How can I go about this? Frown | :-(
AnswerRe: How to count occurences of a number and its most frequent pair in a text file? Pin
Richard MacCutchan25-Apr-20 0:38
mveRichard MacCutchan25-Apr-20 0:38 
AnswerRe: How to count occurences of a number and its most frequent pair in a text file? Pin
Stefan_Lang27-Apr-20 0:32
Stefan_Lang27-Apr-20 0:32 
SuggestionRe: How to count occurences of a number and its most frequent pair in a text file? Pin
David Crow27-Apr-20 2:08
David Crow27-Apr-20 2:08 
Questionarray of 32bit container Pin
Member 1481234224-Apr-20 6:28
Member 1481234224-Apr-20 6:28 
AnswerRe: array of 32bit container Pin
Richard MacCutchan24-Apr-20 6:56
mveRichard MacCutchan24-Apr-20 6:56 
AnswerRe: array of 32bit container Pin
jeron124-Apr-20 7:07
jeron124-Apr-20 7:07 
GeneralRe: array of 32bit container Pin
Richard Andrew x6424-Apr-20 13:09
professionalRichard Andrew x6424-Apr-20 13:09 
GeneralRe: array of 32bit container Pin
jeron124-Apr-20 14:27
jeron124-Apr-20 14:27 
GeneralRe: array of 32bit container Pin
Member 1481234224-Apr-20 20:48
Member 1481234224-Apr-20 20: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.