BleepingComputer.com: Complicated Internal Marticies Addition

Jump to content

  • 3 Pages +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

Complicated Internal Marticies Addition

#31 User is offline   haun 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 156
  • Joined: 01-September 08
  • Gender:Male
  • Location:Denver, CO

Posted 29 January 2009 - 01:00 AM

Ok here is a break through, its adding... the edge is almost exactly what it should be (1,1,2,4,8,16,32,64)

Out:

Quote

|1|128|256|384|512|640|768|896|1024|1152|
|0|128|256|384|512|640|768|896|1024|1152|
|1|129|257|385|513|641|769|897|1025|1153|
|2|130|258|386|514|642|770|898|1026|1154|
|4|132|260|388|516|644|772|900|1028|1156|
|8|136|264|392|520|648|776|904|1032|1160|
|16|144|272|400|528|656|784|912|1040|1168|
|32|160|288|416|544|672|800|928|1056|1184|
|64|192|320|448|576|704|832|960|1088|1216|
|128|256|384|512|640|768|896|1024|1152|1280|


Here is the code:
void rule()
{
size_row = 10; //numbers of rows ( -- )
size_col = 10; //Number or colums ( | )
pre = 0;
for( state_col=0; state_col != size_col; state_col++ ) //collum switch
{
for( state_row = 0; state_row != size_row; state_row++ ) //row switch
{
			 for(row = 0; row != state_row; row++)
			 {
					 if(state_col == 0 && state_row == 0)
								  row = 1;
					 else
					 matrix[0][0] = 1;
					 pre = matrix[row-1][0]+pre;
					 
			 }
			 matrix[state_row][state_col] = pre;
}
}
}

Annnnd you're, asking, me...

#32 User is offline   haun 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 156
  • Joined: 01-September 08
  • Gender:Male
  • Location:Denver, CO

Posted 18 March 2009 - 08:57 AM

YAY its Fixed!

#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstdio>
#include <fstream>

using namespace std;

//Variables
int row; //Used for placing rows in matrix (output_
int col; //col number 
int state_row; //used to state the current place the matrix its adding to
int state_col; 
int loop_row; //used it addition 
int loop_col; 
int size_row = 10; //numbers of rows ( -- )
int size_col = 10; //Number or colums ( | )
int matrix[10][10];
int pre = 0;

// Functions

void txtclr() //Text Clear, used to clear the out file before the next print
{
ofstream UM("Out.txt", ios::out); //Opens "Out.txt" for clean, overwriting
UM.flush(); 
UM.close();
}

void rule()
{
for(state_col = 0; state_col != size_col; state_col++) //switch collums when row is done adding
{
for(state_row = 0; state_row != size_row; state_row++) //switch row after add
{
 			  matrix[0][0] = 1; //Alway start with 1
 			  pre = 0; //reset pre standing
 			  for(loop_row = 0; loop_row != state_row; loop_row++) //retrieves all numbers in row 0-state_row
 			  {
			   			   pre = matrix[loop_row][state_col] + pre; 
			   }
			   for(loop_col = 0; loop_col != state_col; loop_col++) //retrieves all numbers in row 0-state_col
 			  {
			   			   pre = matrix[state_row][loop_col] + pre;
			   }
			   matrix[state_row][state_col] = pre;	  
}						
}
}

void txtprnt() //Text Print, prints out the data from rule() to a file
{
rule(); //Runs the Rule
ofstream UM("Out.txt", ios::out | ios::app); //Dump arrays onto "Out.txt" at end of 
	  for( col = 0; col != size_col; col++ )//Used to advance to next col once the first col is completed
	 {
		  UM << "|"; //Visual Character
		  cout << "|"; //View Real time generation
		  for( row = 0; row != size_row; row++) //Matrix row printer
		  {
			   UM << matrix[row][col] << "|"; //Print the number in the space [row]x[col], and a Visual Character
			   cout << matrix[row][col] << "|"; //View Real time generation
		  }
		  UM << '\n'; //once row completed, move down a line
		  cout << '\n'; //View Real time generation
	 }
	 UM.flush();
	 UM.close();
system("pause");
}
	
//Program

int main(int argc, char *argv[])
{
txtclr(); //Clear text
txtprnt(); //Print text [Generate numbers]
return 0;
}



Quote

|1|1|2|4|8|16|32|64|128|256|
|1|2|5|12|28|64|144|320|704|1536|
|2|5|14|37|94|232|560|1328|3104|7168|
|4|12|37|106|289|760|1944|4864|11952|28928|
|8|28|94|289|838|2329|6266|16428|42168|106336|
|16|64|232|760|2329|6802|19149|52356|139764|365696|
|32|144|560|1944|6266|19149|56190|159645|441750|1195600|
|64|320|1328|4864|16428|52356|159645|470010|1344585|3755120|
|128|704|3104|11952|42168|139764|441750|1344585|3968310|11413105|
|256|1536|7168|28928|106336|365696|1195600|3755120|11413105|33747490|

Annnnd you're, asking, me...

Share this topic:


  • 3 Pages +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users