this should work (generate all the combinations of n dice each with m sides)

Crappy and a little ad-hoc, and no sign of a recursive but it works for most counts.
…could do with handling multiple dice types throwdice(2,3,5,6,6,6,6) and maybe extend it to use a file instead of an array in memory(??).
Still it can push out a prodigious amount of numbers.

#include 
#include 
#include 
#include 
using namespace std;

int throwDice(int intDices,int DiceSides);
long dicecount=7;
int MaxSides=9; //3
long nRows=(int)pow(MaxSides,dicecount);

int* history=new int[nRows * dicecount]; //create a very large 1 dimensional array

int sum=0;
int main()
{

  for (int j=0;j
					

Handy Packages for R

Packages:
lattice
envelope
doBy
RODBC
fArma
BayesX
car
maptools
RColorBrewer

install.packages("lattice", dependencies = TRUE)
install.packages("envelope", dependencies = TRUE)
install.packages("doBy", dependencies = TRUE)
install.packages("RODBC", dependencies = TRUE)
install.packages("fArma", dependencies = TRUE)
install.packages("BayesX", dependencies = TRUE)
install.packages("car", dependencies = TRUE)
install.packages("maptools", dependencies = TRUE)
install.packages("KernSmooth", dependencies = TRUE)
install.packages("RColorBrewer", dependencies = TRUE)

or in one command…

install.packages(c("rJava","lattice","Cairo","xlsx","treemap","RODBC","maptools","doBy","car","RColorBrewer","envelope","BayesX", "KernSmooth"), dependencies = T, repos = "http://cran.fhcrc.org") 

Word count histogram (horizontal)

Take a look at this:

#include 
main()
{
    int wlen[255]; //why would you have a word with more letters than this?
    int i,g,wordcount,lettercount,inner,c,maxVal,maxLet;
    wordcount=lettercount=maxVal=maxLet=0;

    for(i=0;i<=254;++i) wlen[i]=0; //zero out the array

    while ((c=getchar())!=EOF)
    {
        if ((c=='\n'||c=='\t'|| c==' ' || c=='.' || c==',' || c==';' || c==':')&& lettercount>0)
        //don't count double 'spacers' as zero length words
        {
            ++wordcount;
            wlen[lettercount]=wlen[lettercount]+1;
            if (lettercount>maxLet) maxLet=lettercount;
            if (wlen[lettercount]>maxVal) maxVal=wlen[lettercount];
            lettercount=0;
        }
        else ++lettercount;
     }
    for(i=maxVal;i>0;--i)
    {
        for (inner=0;inner<=maxLet;++inner)
        {
           if (wlen[inner]>=i) printf("X");
           else printf(" ");
        }
        printf("\n");
    }
     for (g=0;g<=maxLet;++g)  printf("%d",g);
      printf("\n\nHey Finished Man!!\n");
}

update the main table and several sub tables using the autonumber primary key from the first table…

You’ve got a table (here bed_beds with pk = bed_refno) and you want to insert a new ‘bed’ and update the bed_beds_specialties and bed_sex_status tables using the newly created auto-generated id key.

Create a Stored Procedure (SP) and use the the SCOPE_IDENTITY() function to keep a record of the identity key generated within the scope. Then pass that to the INSERT queries used further down in the SP.


CREATE PROCEDURE spInsert_Bed
@wardRefno numeric(10,0),
@typeRefno numeric(10,0),
@dStart DATETIME,
@dEnd DATETIME,
@dCreate DATETIME,
@vUser VARCHAR(15)
AS
SET NOCOUNT ON
declare @lastin numeric(10,0)
INSERT INTO bed_beds (ward_refno, type_refno, start_Dttm, end_Dttm,create_Dttm,user_create)
VALUES (@wardRefno, @typeRefno, @dStart, @dEnd,@dCreate,@vUser)
set @lastin=  SCOPE_IDENTITY()

INSERT INTO bed_beds_specialties (bed_refno, spect_refno,comments, start_Dttm, end_Dttm,create_Dttm,user_create)
VALUES (@lastin, 3,'my sp test', @dStart, @dEnd,getdate(),@vUser)

INSERT INTO bed_sex_status (bed_refno, start_Dttm, end_Dttm,sex_rfval_refno,create_Dttm,user_create)
VALUES (@lastin,  @dStart,@dEnd,6,getdate(),@vUser)

GO

one loop and a decision

very very basic for loop and if else if else

#include 
using namespace std;
int main()
{
int i;
for(i=0;i<=13;i++)
    {cout << "Hello world! "<< i <

..notice that by the time it leaves the

for (){}

loop it is 14 not 13

Want system pause?

system("PAUSE");

then you'll need:

#include 

Preprocessor directives

An example of some preprocessor stuff:

#include 
#define __thing__ " amazing "
#define __func__(x,y) ((x)>(y)?(x):(y))
#define _FAT_
#define _Cars_
using namespace std;
int main()
{
     cout << "Hello world!"<< __thing__ <
					

C++ MFC

Make sure:

#include "stdafx.h"

comes FIRST otherwise you will get lots of proper errors.

If you see the following error:

error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

Make sure that your linker is set to compile for windows:

Project > Properties > Linker > System > SubSystem
set to
Windows (/SUBSYSTEM:WINDOWS)

Another key hint is to set your

Project > Properties > Configuration Properties > General > Use of MFC

set to:

Use MFC in a Shared DLL