Friday, October 7, 2011

How to write tic tac toe on C# (C sharp)







Hi, now I will show you how to write tic tac toe on C# (C sharp).
First of all you need to add on Form 10 buttons and 4 labels.













The Form should look like this:








After that we will write some C# code:






using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Tic_tac
{
    public partial class Form1 : Form
    {
        bool Player1 = true;
        bool Player2 = false;
        int X = 0;
        int O = 0;


        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button10_Click(object sender, EventArgs e)
        {
            button1.Text = "";
            button2.Text = "";
            button3.Text = "";
            button4.Text = "";
            button5.Text = "";
            button6.Text = "";
            button7.Text = "";
            button8.Text = "";
            button9.Text = "";
            
            Player1 = true;
            Player2 = false;
           

        }

       

        private void button1_Click(object sender, EventArgs e)
        {
            if (Player1 == true)
            {
                //Player1 = true;
                button1.Text = "X";
                Player1 = false;
            }
            else
            {
                Player2 = true;
                button1.Text = "O";
                Player2 = false;
                Player1 = true;
            }  
            Wincombination();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (Player1 == true)
            {
                //Player1 = true;
                button2.Text = "X";
                Player1 = false;
            }
            else
            {
                Player2 = true;
                button2.Text = "O";
                Player2 = false;
                Player1 = true;
            }
            Wincombination();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (Player1 == true)
            {
                //Player1 = true;
                button3.Text = "X";
                Player1 = false;
            }
            else
            {
                Player2 = true;
                button3.Text = "O";
                Player2 = false;
                Player1 = true;
            }

            Wincombination();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (Player1 == true)
            {
                //Player1 = true;
                button4.Text = "X";
                Player1 = false;
            }
            else
            {
                Player2 = true;
                button4.Text = "O";
                Player2 = false;
                Player1 = true;
            }

            Wincombination();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (Player1 == true)
            {
                //Player1 = true;
                button5.Text = "X";
                Player1 = false;
            }
            else
            {
                Player2 = true;
                button5.Text = "O";
                Player2 = false;
                Player1 = true;
            }

            Wincombination();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (Player1 == true)
            {
               // Player1 = true;
                button6.Text = "X";
                Player1 = false;
            }
            else
            {
                Player2 = true;
                button6.Text = "O";
                Player2 = false;
                Player1 = true;
            }

            Wincombination();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            if (Player1 == true)
            {
               // Player1 = true;
                button7.Text = "X";
                Player1 = false;
            }
            else
            {
                Player2 = true;
                button7.Text = "O";
                Player2 = false;
                Player1 = true;
            }

            Wincombination();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            if (Player1 == true)
            {
             //   Player1 = true;
                button8.Text = "X";
                Player1 = false;
            }
            else
            {
                Player2 = true;
                button8.Text = "O";
                Player2 = false;
                Player1 = true;
            }

            Wincombination();
        }

        private void button9_Click(object sender, EventArgs e)
        {
            if (Player1 == true)
            {
             //   Player1 = true;
                button9.Text = "X";
                Player1 = false;
            }
            else
            {
                Player2 = true;
                button9.Text = "O";
                Player2 = false;
                Player1 = true;
            }

            Wincombination();
        }

        private void Wincombination()
        {
            if (button1.Text == "X" && button2.Text == "X" && button3.Text == "X")
            {
                MessageBox.Show("X Win!", "Game over", MessageBoxButtons.OK);
                X = X + 1;
                label1.Text = X.ToString("");
            }
            if (button4.Text == "X" && button5.Text == "X" && button6.Text == "X")
            {
                MessageBox.Show("X Win!", "Game over", MessageBoxButtons.OK);
                X = X + 1;
                label1.Text = X.ToString("");
            }
            if (button7.Text == "X" && button8.Text == "X" && button9.Text == "X")
            {
                MessageBox.Show("X Win!", "Game over", MessageBoxButtons.OK);
                X = X + 1;
                label1.Text = X.ToString("");
            }

            if (button1.Text == "X" && button5.Text == "X" && button9.Text == "X")
            {
                MessageBox.Show("X Win!", "Game over", MessageBoxButtons.OK);
                X = X + 1;
                label1.Text = X.ToString("");
            }
            if (button3.Text == "X" && button5.Text == "X" && button7.Text == "X")
            {
                MessageBox.Show("X Win!", "Game over", MessageBoxButtons.OK);
                X = X + 1;
                label1.Text = X.ToString("");
            }

            if (button1.Text == "X" && button4.Text == "X" && button7.Text == "X")
            {
                MessageBox.Show("X Win!", "Game over", MessageBoxButtons.OK);
                X = X + 1;
                label1.Text = X.ToString("");
            }
            if (button2.Text == "X" && button5.Text == "X" && button8.Text == "X")
            {
                MessageBox.Show("X Win!", "Game over", MessageBoxButtons.OK);
                X = X + 1;
                label1.Text = X.ToString("");
            }
            if (button3.Text == "X" && button6.Text == "X" && button9.Text == "X")
            {
                MessageBox.Show("X Win!", "Game over", MessageBoxButtons.OK);
                X = X + 1;
                label1.Text = X.ToString("");
            }

            // for O

            if (button1.Text == "O" && button2.Text == "O" && button3.Text == "O")
            {
                MessageBox.Show("O Win!", "Game over", MessageBoxButtons.OK);
                O = O + 1;
                label2.Text = O.ToString("");
            }
            if (button4.Text == "O" && button5.Text == "O" && button6.Text == "O")
            {
                MessageBox.Show("O Win!", "Game over", MessageBoxButtons.OK);
                O = O + 1;
                label2.Text = O.ToString("");
            }
            if (button7.Text == "O" && button8.Text == "O" && button9.Text == "O")
            {
                MessageBox.Show("O Win!", "Game over", MessageBoxButtons.OK);
                O = O + 1;
                label2.Text = O.ToString("");
            }

            if (button1.Text == "O" && button5.Text == "O" && button9.Text == "O")
            {
                MessageBox.Show("O Win!", "Game over", MessageBoxButtons.OK);
                O = O + 1;
                label2.Text = O.ToString("");
            }
            if (button3.Text == "O" && button5.Text == "O" && button7.Text == "O")
            {
                MessageBox.Show("O Win!", "Game over", MessageBoxButtons.OK);
                O = O + 1;
                label2.Text = O.ToString("");
            }

            if (button1.Text == "O" && button4.Text == "O" && button7.Text == "O")
            {
                MessageBox.Show("O Win!", "Game over", MessageBoxButtons.OK);
                O = O + 1;
                label2.Text = O.ToString("");
            }
            if (button2.Text == "O" && button5.Text == "O" && button8.Text == "O")
            {
                MessageBox.Show("O Win!", "Game over", MessageBoxButtons.OK);
                O = O + 1;
                label2.Text = O.ToString("");
            }
            if (button3.Text == "O" && button6.Text == "O" && button9.Text == "O")
            {
                MessageBox.Show("O Win!", "Game over", MessageBoxButtons.OK);
                O = O + 1;
                label2.Text = O.ToString("");
            }


        }

        private void newGameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            button1.Text = "";
            button2.Text = "";
            button3.Text = "";
            button4.Text = "";
            button5.Text = "";
            button6.Text = "";
            button7.Text = "";
            button8.Text = "";
            button9.Text = "";

            Player1 = true;
            Player2 = false;
            X = 0;
            O = 0;
            label1.Text = "0";
            label2.Text = "0";
        }

        private void exitToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Tic-Tac-Toe 1.0 by Bogdan Ustyak");
        }
    }
}

ASP.NET








ASP.NET - technology for creating web applications and Web services from Microsoft. It is part of the Microsoft. NET and development of older technologies Microsoft ASP. Currently, the latest version of this technology is ASP.NET 4.0. 
ASP.NET outwardly retains much similarity with the older technology of ASP, which allows developers to relatively easily move to ASP.NET. At the same time the internal structure of ASP.NET is very different from ASP, as it is based on the platform. NET and, therefore, uses all the new possibilities offered by this platform.



History ASP.NET 


After releasing the server Internet Information Services 4.0 in 1997, Microsoft began to explore the possibility of a new model of Web applications that satisfy the complaints of ASP, particularly those associated with the separation of design from content, and which will write "clean" code. Work to develop such a model was assigned to Mark Anders, manager of the team IIS, and Scott Hutri who started work at Microsoft in 1997. Anders Hutri and developed the initial draft within two months, and wrote code Hutri initial prototype during the Christmas holidays of 1997. 
The initial project called «XSP»; Hutri explained in an interview in 2007 that "always ask what it means to the letter X. At that time it meant nothing. XML starts with her; XSLT starts with her. Everything cool starts with X, so we got the name. "Prototype of XSP was written in Java, but soon decided to build a new platform based on the Common Language Runtime (CLR), because it is present on the principles of OOP programming, garbage collection and other possibilities. Hutri described this decision as a "huge risk" because the success of the new development was linked to the success CLR, which, like XSP, was at an early stage of development.



Principles ASP.NET 


Even though ASP.NET takes its name from the old technology of Microsoft ASP, it differs significantly from it. Microsoft completely rebuilt ASP.NET, based on the Common Language Runtime (CLR), which is the foundation of all applications, Microsoft. NET. Developers can write code for ASP.NET, using virtually any programming language included in the kit. NET Framework (C #, Visual Basic.NET, and JScript. NET). ASP.NET has the advantage in speed compared to scripting technologies, so that when the first reference code is compiled and placed in a special cache, and then only performed without requiring the time for parsing, optimization, etc.



Advantages of ASP.NET to ASP 


   Compiled code is faster, most errors vidlovlyuyetsya still under construction 
   Much improved error handling run-time, using blocks try .. catch 
  Custom Controls (controls) allow you to highlight commonly used templates, such as site menu 
  Using metaphors, already used in Windows-applications, such as controls and events  
   Extensible set of controls and class libraries allows you to quickly develop applications 
   ASP.NET is based on the multilingual capabilities. NET, which allows you to write code      pages in VB.NET, Delphi.NET, Visual C / C + +, etc. 
  Ability to cache the entire page or part thereof to increase productivity 
  Possibility of caching data that are used on the page 
  Possibility of separation of visual and business logic from different files («code behind») 
  Extensible query processing model 
  The city expanded model 
  Extensible model of server controls 
  The presence of master-pages task templates pages 
  Support for CRUD-operations in a spreadsheet via GridView 
  Built-in support for AJAX 
  ASP.NET has the advantage in speed compared to other technologies, based on scripts. 
  You can give some comparison. Thus, ASP - derived from Win32, XML and HTML; PHP - from XML, HTML, Java, and CDI, then ASP.NET - from HTML and. NET (XML and XAML, respectively). However, if usually Rich Media Application created by Flash, now it is done with the module Silverlight, just because he ASP.NET. ASP.NET - richer environment for the development and deployment of web resources. In ASP.NET you can work with any. NET language, even to the Managed C + + and Visual Basic, which allows not to think about moving to C #. 


Expansion 


Microsoft has released several extensions to ASP.NET: 
ASP.NET AJAX 
ASP.NET MVC Framework



Microsoft. NET Framework



    Microsoft. NET (read dot-net) - software technology offered by Microsoft as a platform for creating both conventional programs and web applications. In many ways a continuation of the ideas and principles that are the technology of Java.
One of the ideas. NET is compatible services written in different languages. Although this opportunity is advertised as a benefit of Microsoft. NET, Java platform has the same opportunity.

    Each library (assembly) in. NET is a testimony of his version, which allows to eliminate possible conflicts between different versions of assemblies.
    .NET - cross-platform technology currently exists for the implementation of the Platform Microsoft Windows, FreeBSD (from Microsoft) and a variant of Linux technology for the project Mono (under an agreement between Microsoft with Novell), DotGNU [1].

    Copyright protection applies to a runtime (CLR - Common Language Runtime) for programs. NET. Compiler. NET produced by many companies for different languages ​​freely.

    . NET is divided into two main parts - the runtime (essentially a virtual machine) and development tools.
Development environment. NET-applications: Visual Studio. NET (C + +, C #, J #), SharpDevelop, Borland Developer Studio (Delphi, C #) and so is the Eclipse application development. NET-applications. Applicable program can also devise a text editor and use the command-line compiler.

    As technology is Java, development environment. NET generates byte code designed to perform a virtual machine. Input language of the machine in. NET is called CIL (Common Intermediate Language), also known as MSIL (Microsoft Intermediate Language), or just IL. The use of byte-code allows you krossplatformenist at precompiled project (in terms of. NET: collection), but not at the level of the original text, such as in C. Before starting the assembly in runtime (CLR) byte-code is converted into a built environment JIT-compiler (just in time, compiling on the fly) into machine code target processor.

    It should be noted that one of the first JIT-Compiler for Java was also developed by Microsoft (currently in Java using a multilevel perfect compilation - Sun HotSpot). Modern technology allows dynamic compilation to achieve the same level of performance with traditional 'static' compilers (like C + +) and performance issues often depends on the quality of a compiler.

Sunday, October 2, 2011

Hi, I created one more blog.
http://it-steel.blogspot.com/
So use it with pleasure.

С# (C-Sharp) - object-oriented programming language


 


      C # (pronounced C-Sharp) - object-oriented programming language with a secure system for typing platform. NET. A Heylsberhom Anders, Scott and Peter Golde Viltamutom under the auspices of Microsoft Research (with firm Microsoft).
      C # syntax similar to C + + and Java. It has a strict static typification, supports polymorphism, overloading operators, pointers to function members of classes, attributes, events, properties, exceptions, comments in XML. Pereynyavshy many of his predecessors - like C + +, Delphi, module and Smalltalk - C #, based on the practice of their use, excludes some models that have proven to be problematic in developing software systems: yes, C # does not support multiple inheritance of classes ( Unlike C + +) or output types (in contrast to Haskell).

      History of ...

        C # is a very close to the programming language Java. The language Java was created by Sun Microsystems, when the global development of the Internet made the task of computing facilities scattered. Based on the popular language C + +, Java has excluded it from potentially dangerous items (such as pointers, without going beyond). For facilities scattered computing concept was created virtual machine and machine-independent byte-code, a kind of mediator between source code and hardware instructions a computer or other device.
Java has acquired considerable popularity, and was also licensed by Microsoft. But over time, Sun began to blame Microsoft, and that before creating a clone of Java makes it compatible only with platform Windows, what supeprechyt very concept of machine-independent execution environment and violates the license agreement. Microsoft refused to meet the requirements of the Sun, and therefore determine the relationship has taken on trial. The Court found the position of fair Sun, and ordered Microsoft to abandon pozalitsenziynoho use Java.
In this situation, Microsoft decided to use their weight on the market, create your own analogue of Java, the language in which the corporation will povnovlasnym master. This newly created language called C #. She inherited the concept of Java Virtual Machine (environment. NET), the bytecode (MSIL) and more security source code, plus take into account the experience of programs in Java.
An innovation was the ability to C # easier interaction, compared to the predecessor languages, code programs written in other languages ​​that are important in creating large projects. If the program in different languages ​​running on the platform. NET,. NET is the charge on application compatibility (ie, data types, with the final score).
As of today, C # language defines flagship corporation Microsoft, because it most fully exploits new opportunities. NET. Other programming languages, although supported, but recognized as having hereditary gaps to use. NET.


Name of language

      The # in the name of the language can be interpreted also as two pairs of pluses + +, that hint at a new step in language development compared to C + + (like the step from C to C + +), and as a musical symbol sharp, along with the letter C, which is in English to name the notes-sharp. The latter gave the name of the language. Despite the fact that the symbol # (oktotorp) is actually a symbol to indicate the number of most keyboards and different from the sharp symbol ♯ (Unicode U +266 F), Microsoft, as the author of the language, have repeatedly appealed to their customers asking to take such styling.


Features of Language 

      C # was developed as a programming language for application-level CLR and, as such, depends primarily on the capabilities of the CLR. This applies, above all, types of C #. The presence or absence of certain features of expressive language is dictated by whether a particular linguistic feature to be broadcast in the relevant design CLR. Thus, the development of CLR version 1.1 to 2.0 significantly enriched himself C #; such interaction should be expected to continue. (However, this pattern is broken with the release of C # 3.0, which is a language extension that does not rely on the extension platform. NET.) CLR provides C #, like all others. NET-oriented languages ​​has many features that may be deprived of "classic" programming languages . For example, garbage collection is not implemented in the C #, and CLR performed for programs written in C # exactly as it is done for programs in VB.NET, J #, etc..


Example «Hello, World»

using System;
 
class ExampleClass
{
  static void Main()
  {
    Console.WriteLine("Hello, world!");
  }
}



Saturday, October 1, 2011

Gauss - Jordan method delphi / pascal / c#

  Today I have wrote Gauss - Jordan method on C# and delphi. It's also can be used on Pascal, you just need to rewrite it, without any problems.
Procedure written on C# is in the end of article.
   Program result you will find in text file "Result".
   There are couple procedures like "readFile" that read matrix from text file. In files there are such matrix:
1:
1 -4 -3 8
2 -6 -4 2
3 -8 1 -4
4 2 2 -6


2:
0 1 -6 -4
3 -1 -6 -4
2 3 9 2
3 2 3 8


3:
-3 -3 4
0 -1 0
6 2 -4

4:
-3 -3 2
0 -1 0
6 2 -4

So here it is...


program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type TMatrix = array [1..50,1..50] of real;
     TVect = array [1..50] of real;
     TFile = textFile;

var A: TMatrix ; b:TVect; n, per:integer; t,f:TFile; c:byte; s:string;

 procedure readFile(var A:TMatrix; var n:integer);
  var i,j:integer;
   begin  i:=1; j:=1;
    while not eof(t) do
     begin j:=1;
       while not eoln(t) do
         begin
           read(t,a[i,j]);
           inc(j);
         end;
         readln(t);
         inc(i);
     end;
     closeFile(t);
   end;


procedure setMatrix(var A:TMatrix; var n:integer);
var i,j:integer;
 begin
 writeln('Input Matrix A');
  for i := 1 to n do
   for j := 1 to n do
   begin
      write ('a',i,',', j ,'=');
    readln(A[i,j]);
   end;
  end;

procedure setVect(var b:TVect; var n:integer);
   var i:integer;
    begin
      for i := 1 to n do
      begin
        write ('b',i,'=');
        readln(b[i]);
      end;
    end;

procedure Gauss (A:TMatrix;b:TVect; n:integer);
var
  i, j, k,step:integer;    R,det,p:real;
       x:TVect;
 begin
 per:=1;
  for i := 1 to N - 1 do
   begin
    k := i;
    R := Abs(A[i, i]);
    for j := i + 1 to N do
     if (Abs(A[j, i]) >= R) then
      begin
       k := j;
       R := Abs(A[j, i]);
      end;
     if (k <> i) then
      begin
       R := B[k];
       B[k] := B[i];
       B[i] := R;
       for j := i to N do
        begin
         R := A[k, j];
         A[k, j] := A[i, j];
         A[i, j] := R;
        end;
       end;
                 R := A[i, i];
                  if R = 0 then  begin writeln('Denom <0'); readln; halt; end;
                 B[i] := B[i] / R;
                 for j := 1 to N do
                   begin
                    if R = 0 then begin writeln('Denom <0'); readln;  halt; end;
                     A[i, j] := A[i, j] / R;
                   end;
                 for k := i + 1 to N do
                 begin
                     R := A[k, i];
                     B[k] := B[k] - R * B[i];
                     A[k, i] := 0;
                     for j := i + 1 to N do
                        A[k, j] := A[k, j] - R * A[i, j];
                 end;
        end;
          if A[N,N] = 0 then begin writeln('Denom <0');readln;  halt; end;
         X[N] := B[N] / A[N, N];

         for i := N - 1 downto 1 do
         begin
             R := B[i];
             for j := i + 1 to N do
                 R := R - A[i, j] * X[j];
             X[i] := R;

          per:=per+1;
         end;


         for i:= 1 to n do
           writeln('x',i,'= ',x[i]:5:2);
 end;

procedure showMatrix(A:TMatrix; n:integer);
    var i,j:integer;
  begin
    for i := 1 to n do
    begin
      for j := 1 to n do
        write(A[i,j]:4:2,' ');
        writeln;
    end;
  end;

procedure Determinant;
var   i,step,k:integer;
      p,det:real;
begin
p:=1;
       step:=1;
       for i:=1 to per do
        step:=step*(-1);
       for k:=1 to n do
             begin
              p:=p * a[k,k];
              det:=p * step;
            end;
            writeln('Determinant = ', det:5:2);
end;


 procedure writeFile(x:TVect);
     var i:integer;
   begin
     for i := 1 to n do
       write(f,x[i],' ');
   end;

begin
writeln('Which matrix do you want to calculate');
readln(c);
case c of
1:
  begin
    s:='Matrix1.txt';
    n:=4;
  end;
2:
  begin
    s:='Matrix2.txt';
    n:=4
  end;
3:
  begin
    s:='Matrix3.txt';
    n:=3;
  end;
4:
  begin
    s:='Matrix4.txt';
    n:=3;
  end;
end;

assignFile(t,s);
reset(t);
//setMatrix(A,n);
readFile(A,n);
showMatrix(A,n);
setVect(B,n);


AssignFile(f,'Result.txt');
Rewrite(f);
Gauss(a,b,n);
determinant;
writeFile(b);
CloseFile(f);
writeln('Results are in text file "Results"');
readln
end.

//==============================================
//Procedure written on C#


static public void Gauss (ref double[,] A, ref double[] B, int N,
ref double[] X)
 {
  int i, j, k;
  double R;
  for (i = 1; i <= N - 1; i++)
   {
    k = i;
    R = Math.Abs(A[i, i]);
    for (j = i + 1; j <= N; j++)
     if (Math.Abs(A[j, i]) >= R)
      {
       k = j;
       R = Math.Abs(A[j, i]);
      }
     if (k != i)
      {
       R = B[k];
       B[k] = B[i];
       B[i] = R;
       for (j = i; j < N; j++)
        {
         R = A[k, j];
         A[k, j] = A[i, j];
         A[i, j] = R;
        }
       }
                 R = A[i, i];
                 B[i] = B[i] / R;
                 for (j = 1; j <= N; j++)
                     A[i, j] = A[i, j] / R;
                 for (k = i + 1; k <= N; k++)
                 {
                     R = A[k, i];
                     B[k] = B[k] - R * B[i];
                     A[k, i] = 0;
                     for (j = i + 1; j <= N; j++)
                         A[k, j] = A[k, j] - R * A[i, j];
                 }
             }
         X[N] = B[N] / A[N, N];
         for (i = N - 1; i >= 1; i--)
         {
             R = B[i];
             for (j = i + 1; j <= N; j++)
                 R = R - A[i, j] * X[j];
             X[i] = R;
         }
     }
 }


// program written on C++ from dreamincode.net


/******************************************************************************/
/* Perform Gauss-Jordan elimination with row-pivoting to obtain the solution to
 * the system of linear equations
 * A X = B
 *
 * Arguments:
 * lhs - left-hand side of the equation, matrix A
 * rhs - right-hand side of the equation, matrix B
 * nrows - number of rows in the arrays lhs and rhs
 * ncolsrhs- number of columns in the array rhs
 *
 * The function uses Gauss-Jordan elimination with pivoting.  The solution X to
 * the linear system winds up stored in the array rhs; create a copy to pass to
 * the function if you wish to retain the original RHS array.
 *
 * Passing the identity matrix as the rhs argument results in the inverse of
 * matrix A, if it exists.
 *
 * No library or header dependencies, but requires the function swaprows, which
 * is included here.
 */

//  swaprows - exchanges the contents of row0 and row1 in a 2d array
void swaprows(double** arr, long row0, long row1) {
    double* temp;
    temp=arr[row0];
    arr[row0]=arr[row1];
    arr[row1]=temp;
}

// gjelim
void gjelim(double** lhs, double** rhs, long nrows, long ncolsrhs) {

    // augment lhs array with rhs array and store in arr2
    double** arr2=new double*[nrows];
    for (long row=0; row<nrows; ++row)
        arr2[row]=new double[nrows+ncolsrhs];

    for (long row=0; row<nrows; ++row) {
        for (long col=0; col<nrows; ++col) {
            arr2[row][col]=lhs[row][col];
        }
        for (long col=nrows; col<nrows+ncolsrhs; ++col) {
            arr2[row][col]=rhs[row][col-nrows];
        }
    }

    // perform forward elimination to get arr2 in row-echelon form
    for (long dindex=0; dindex<nrows; ++dindex) {
        // run along diagonal, swapping rows to move zeros in working position
        // (along the diagonal) downwards
        if ( (dindex==(nrows-1)) && (arr2[dindex][dindex]==0)) {
            return; //  no solution
        } else if (arr2[dindex][dindex]==0) {
            swaprows(arr2, dindex, dindex+1);
        }
        // divide working row by value of working position to get a 1 on the
        // diagonal
        if (arr2[dindex][dindex] == 0.0) {
            return;
        } else {
            double tempval=arr2[dindex][dindex];
            for (long col=0; col<nrows+ncolsrhs; ++col) {
                arr2[dindex][col]/=tempval;
            }
        }

        // eliminate value below working position by subtracting a multiple of
        // the current row
        for (long row=dindex+1; row<nrows; ++row) {
            double wval=arr2[row][dindex];
            for (long col=0; col<nrows+ncolsrhs; ++col) {
                arr2[row][col]-=wval*arr2[dindex][col];
            }
        }
    }

    // backward substitution steps
    for (long dindex=nrows-1; dindex>=0; --dindex) {
        // eliminate value above working position by subtracting a multiple of
        // the current row
        for (long row=dindex-1; row>=0; --row) {
            double wval=arr2[row][dindex];
            for (long col=0; col<nrows+ncolsrhs; ++col) {
                arr2[row][col]-=wval*arr2[dindex][col];
            }
        }
    }

    // assign result to replace rhs
    for (long row=0; row<nrows; ++row) {
        for (long col=0; col<ncolsrhs; ++col) {
            rhs[row][col]=arr2[row][col+nrows];
        }
    }

    for (long row=0; row<nrows; ++row)
        delete[] arr2[row];
    delete[] arr2;
}




How to make money online with google adsense.

    So in this article you will find the answer how to make money online with your site. I prefer blogging on blogger.com so I don't have to buy any domain names or hosting, and I have a blog that can help me to earn money.
    So watch this video and after learning, make money online with google adsense!!!
    Here you are...

Thanks for your time. Hope you have found information you needed.

What programming language I should chose to become a successful programmer.

   All right . So you want to become a programmer. Firstly you should understand who is a programmer. It's not a gamer, so if you are playing games on your PC or play station you are NOT a programmer, but sometimes it's an useful thing. Some IT companies are looking for such people, such programmers, who are interested in games, so they could create their own games and different interesting projects. But it's another topic, that I will of course describe but not now.
   So, if you want to become a programmer, you need to choose what do you want to do. It can be web, or applied programming, for example. It can be different sites, applications, programs like text or music,video... readers or if you are interested in all these stuffs you can learn everything but you should remember that you can't know everything. My math teacher always said to me : "Smart man don't know everything, but knows where to find information he need". So it's your choice!
  I should warn you that I am interested in applied programming so I will describe mostly it, not web.
 After that, you need to choose what programming language you want to learn. As for me the most interesting is the next combination: Object Pascal then Delphi then C++ then C# and then ....hm....maybe java:)
  In our time I think that the best languages for applied programming are C# and java. Of course if you want to write your own OS (operative system) so you should prefer C++.
  Emm...Maybe it's all for this publication. Please don't judge me if there you don't like this article...I'm just starting:)

My first publication.

Hello!)