online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** Online C# Compiler. Code, Compile, Run and Debug C# program online. Write your code in this editor and press "Run" button to execute it. *******************************************************************************/ using System; class HelloWorld { public static void Game(char[,]S) { //1 S[0,0] = 'O'; S[1,1] = 'X'; S[2,2] = 'O'; for (int i = 0; i <S.GetLength(0); i++) { if (i % 2 == 0) S[i, i] = 'O'; else S[i, i] = 'X'; } } public static void Print(char[,] S) { Console.Clear(); for (int i = 0; i < S.GetLength(0); i++) { for (int k = 0; k < S.GetLength(1); k++) { Console.Write("{0}|",S[i,k]); } //Console.WriteLine(); //for (int k = 0; k < S.GetLength(1); k++) //{ // Console.Write("{0}|", "-"); //} Console.WriteLine(); } } public static void Play(char[,]S) { int i = 0; char gChar = 'O'; char bChar = 'X'; Random rd = new Random(); int c = rd.Next(2); if (c==0) { gChar = 'X'; bChar = 'O'; } Console.WriteLine("X- Boys , O - Girls. {0} Starts ",bChar); //for (int i = 0; i < S.Length; i++) while (i<S.Length&&!IsWin(S)) { //1 if(i%2==0) Console.WriteLine("Round {0}: {1} Turn ",i,bChar); else Console.WriteLine("Round {0}: {1} Turn ", i, gChar); Console.WriteLine(); Console.Write("Please Enter Row :"); int R = int.Parse(Console.ReadLine()); Console.Write("Please Enter Column:"); int C = int.Parse(Console.ReadLine()); if(R >= S.GetLength(0) || C >= S.GetLength(1)) { if (i % 2 == 0) Console.WriteLine("Girls are lost."); else Console.WriteLine("Boys are lost."); return; } else { if (i % 2 == 0) S[R, C] = bChar; else S[R, C] = gChar; Print(S); } i++; } Console.WriteLine("While Ended"); } public static bool IsWin(char[,] S) { if (IsFirst(S)) return true; if (IsSecond(S)) return true; for (int i = 0; i < S.GetLength(0); i++) { if (IsRowWin(S, i) == true) return true; } for (int i = 0; i < S.GetLength(1); i++) { if (IsColWin(S, i) == true) return true; } return false; } public static bool IsRowWin(char[,] S,int r) { int Xcount = 0; int Ocount = 0; for (int i = 0; i < S.GetLength(1); i++) { if (S[r, i] == 'X') { Xcount++; } if (S[r, i] == 'O') { Ocount++; } } if (Xcount == 3 || Ocount == 3) return true; return false; } public static bool IsColWin(char[,] S, int r) { int Xcount = 0; int Ocount = 0; for (int i = 0; i < S.GetLength(0); i++) { if (S[i, r] == 'X') { Xcount++; } if (S[i, r] == 'O') { Ocount++; } } if (Xcount == 3 || Ocount == 3) return true; return false; } public static bool IsFirst(char[,] S) { int Xcount = 0; int Ocount = 0; for (int i = 0; i < S.GetLength(0); i++) { if (S[i, i] == 'X') { Xcount++; } if (S[i, i] == 'O') { Ocount++; } } if (Xcount == 3 || Ocount == 3) return true; return false; } public static bool IsSecond(char[,] S) { int Xcount = 0; int Ocount = 0; int N = S.GetLength(0)-1; for (int i = 0; i < S.GetLength(0); i++) { if (S[i, N-i] == 'X') { Xcount++; } if (S[i, N-i] == 'O') { Ocount++; } } if (Xcount == 3 || Ocount == 3) return true; return false; } static void Main() { Console.WriteLine("Hello World"); char[,] Board = new char[3, 3]; Print(Board); Play(Board); Console.Write("Game Ended"); } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue