// Justin C. Miller
// 3-27-2001
// made for: http://www.geocities.com/neonprimetime.geo/index.html
// made on: Unix Lab g++ compiler
// Title : rolling dice (2 dimensional array)
// Description: rolls dice, keeps track with a table of the rolls for each possible pair 
//           notice: (1,2) is different that (2,1) in this example (order matters)

#include 
#include 
#include 
#include 
        
int rolldice() ;
                   
int main() {
	srand(time(0)) ;
	int array[6][6] ;
	int i, j ;
	int rolls = 2500 ;   // number of rolls

	for(i = 0 ; i < 6 ; i++)
		for(j = 0 ; j < 6 ; j++)
			array[i][j] = 0 ;

	for(i = 0 ; i < rolls ; i++)
		array[rolldice()-1][rolldice()-1]++ ;

	cout << "Table after " << rolls << " rolls..." << endl ;
	cout << "  " ;
	for(i = 1 ; i <= 6 ; i++) cout << setiosflags(ios::fixed) << setw(4) << i ; // column number
	cout << endl ;
	for(i = 0 ; i < 6 ; i++){
		cout << (i+1) << ".) " ;   // row number
		for(j = 0 ; j < 6 ; j++)
			cout << setiosflags(ios::fixed) << setw(3) << array[i][j] << " " ;
		cout << endl ;			
	}	

	cout << endl ;	
	cout << "% after " << rolls << " rolls..." << endl ;
        cout << "   " ;
        for(i = 1 ; i <= 6 ; i++) cout << setiosflags(ios::fixed) << setw(5) << i ; // column number
        cout << endl ;
        for(i = 0 ; i < 6 ; i++){
                cout << (i+1) << ".) " ;   // row number
                for(j = 0 ; j < 6 ; j++)
                        cout << setiosflags(ios::fixed | ios::showpoint)  << setprecision(2) << ((double)array[i][j] / (double)rolls) << " " ;
                cout << endl ;
        }   

	return 0;
}

int rolldice() { return (rand() % 6 + 1) ;}

    Source: geocities.com/neonprimetime.geo/cpp/cpp_SourceCode

               ( geocities.com/neonprimetime.geo/cpp)                   ( geocities.com/neonprimetime.geo)