15,909,530 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 9411249 (Top 49 by date)
Member 9411249
6-May-14 14:34pm
View
i don't know stuck there, no its not syntax error...
Member 9411249
6-May-14 14:31pm
View
yes, its give 12 errors when i put #include <stdlib.h>
Member 9411249
6-May-14 14:26pm
View
please run it, then you know better
Member 9411249
6-May-14 14:14pm
View
i did this but i put this lib, its give more error :(
Member 9411249
6-May-14 12:37pm
View
Done but not work for me
Member 9411249
6-May-14 12:35pm
View
who have answers, please run this code one time so you can understand because i tried many thing but not worked for me
Member 9411249
8-Dec-13 3:45am
View
Thank You for helping me... :)
Member 9411249
8-Dec-13 3:41am
View
The whole code is here.
public class Sudoku {
public static void main(String[] args) {
// Read a Sudoku puzzle
int[][] grid = readAPuzzle();
if (!isValid(grid))
System.out.println("Invalid input");
else if (search(grid)) {
System.out.println("The solution is found:");
printGrid(grid);
}
else
System.out.println("No solution");
}
/** Read a Sudoku puzzle from the keyboard */
public static int[][] readAPuzzle() {
// Create a Scanner
Scanner input = new Scanner(System.in);
System.out.println("Enter a Sudoku puzzle:");
int[][] grid = new int[9][9];
for (int i = 0; i < 9; i++)
for (int j = 0; j < 9; j++)
grid[i][j] = input.nextInt();
return grid;
}
/** Obtain a list of free cells from the puzzle */
public static int[][] getFreeCellList(int[][] grid) {
// Determine the number of free cells
int numberOfFreeCells = 0;
for (int i = 0; i < 9; i++)
for (int j = 0; j < 9; j++)
if (grid[i][j] == 0)
numberOfFreeCells++;
// Store free cell positions into freeCellList
int[][] freeCellList = new int[numberOfFreeCells][2];
int count = 0;
for (int i = 0; i < 9; i++)
for (int j = 0; j < 9; j++)
if (grid[i][j] == 0) {
freeCellList[count][0] = i;
freeCellList[count++][1] = j;
}
return freeCellList;
}
/** Print the values in the grid */
public static void printGrid(int[][] grid) {
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++)
System.out.print(grid[i][j] + " ");
System.out.println();
}
}
/** Search for a solution */
public static boolean search(int[][] grid) {
int[][] freeCellList = getFreeCellList(grid); // Free cells
if (freeCellList.length == 0)
return true; // "No free cells");
int k = 0; // Start from the first free cell
while (true) {
int i = freeCellList[k][0];
int j = freeCellList[k][1];
if (grid[i][j] == 0)
grid[i][j] = 1; // Fill the free cell with number 1
if (isValid(i, j, grid)) {
if (k + 1 == freeCellList.length) { // No more free cells
return true; // A solution is found
}
else { // Move to the next free cell
k++;
}
}
else if (grid[i][j] < 9) {
// Fill the free cell with the next possible value
grid[i][j] = grid[i][j] + 1;
}
else { // free cell grid[i][j] is 9, backtrack
while (grid[i][j] == 9) {
if (k == 0) {
return false; // No possible value
}
grid[i][j] = 0; // Reset to free cell
k--; // Backtrack to the preceding free cell
i = freeCellList[k][0];
j = freeCellList[k][1];
}
// Fill the free cell with the next possible value,
// search continues from this free cell at k
grid[i][j] = grid[i][j] + 1;
}
}
}
/** Check whether grid[i][j] is valid in the grid */
public static boolean isValid(int i, int j, int[][] grid) {
// Check whether grid[i][j] is valid at the i's row
for (int column = 0; column < 9; column++)
if (column != j && grid[i][column] == grid[i][j])
return false;
// Check whether grid[i][j] is valid at the j's column
for (int row = 0; row < 9; row++)
if (row != i && grid[row][j] == grid[i][j])
return false;
// Check whether grid[i][j] is valid in the 3 by 3 box
for (int row = (i / 3) * 3; row < (i / 3) * 3 + 3; row++)
for (int col = (j / 3) * 3; col < (j / 3) * 3 + 3; col++)
if (row != i && col != j && grid[row][col] == grid[i][j])
return false;
return true; // The current value at grid[i][j] is valid
}
/** Check whether the fixed cells are valid in the grid */
public static boolean isValid(int[][] grid) {
for (int i = 0; i < 9; i++)
for (int j = 0; j < 9; j+
Member 9411249
29-Nov-13 13:57pm
View
Console.WriteLine(endl<<"2:T-NAWAJ"<<endl;??
COnsole.WriteLine("/n"+"NAWAJ"+"/n"); it is true?
how to give line break in C# in one line?
Member 9411249
29-Nov-13 13:48pm
View
Ohh Sorry
Member 9411249
29-Nov-13 13:43pm
View
public void mon()
{
Console.WriteLine("mon mat cse che eee L me1270 ");
Console.WriteLine("/n,/n");
Console.WriteLine(" JAHID AJHER MORSHAD DABROTO LIAJE & SULTAN ");
return 0;
}
It is true? if its then its giving redline under return 0
Member 9411249
29-Nov-13 13:40pm
View
its a C++ Code i m trying to convert it in C#
Member 9411249
29-Nov-13 13:38pm
View
OK thanks
Member 9411249
1-Nov-13 3:27am
View
Have seen already but not to clear about these one's
Member 9411249
11-Oct-13 8:20am
View
i had done, but dnt garrenty that am i do right or wrong... :)
Member 9411249
11-Oct-13 8:19am
View
i want answers to match with my answers because i don't have an sql server right now.
Member 9411249
11-Oct-13 8:18am
View
hehe its look like home work but note home work, i collected quires for my practice to understand SQL in right way....
Member 9411249
3-Oct-13 10:30am
View
I tried this but this is not done
Member 9411249
3-Oct-13 10:29am
View
Noo this is not work for me :(
Member 9411249
8-May-13 15:36pm
View
Oops ok then and thanks...:)
Member 9411249
8-May-13 15:19pm
View
no its not black in black:) i think you check out some thing else/by mistake/mis understand check www.wasay.me
Member 9411249
8-May-13 14:38pm
View
check www.wasay.me and then go to about pg first line in coming up on that pg and same as last pg...
Member 9411249
15-Mar-13 11:26am
View
ok Thanks its Done
Member 9411249
15-Mar-13 11:13am
View
i am new in Coding and i dnt know how to make method specially no idea how to make for it. no its not home work i am try to learning
Member 9411249
15-Mar-13 11:02am
View
Sorry,but every one is differ from others
Member 9411249
14-Jan-13 3:02am
View
i also don't understand 1st step to recieve msgs...
Member 9411249
14-Jan-13 3:01am
View
yes i will try many codes but no one use full. i also stuck on send multi msgs but its works for me with some problems...
Member 9411249
13-Jan-13 13:53pm
View
?
Member 9411249
8-Jan-13 6:53am
View
yes i am using turboC compiler
Member 9411249
8-Jan-13 6:43am
View
no its not my home work i am preparing for my test and i will not use pointers for finding 2d array
Member 9411249
24-Dec-12 13:55pm
View
i am trying that how to i move a circle around screen like diamod shape
Member 9411249
24-Dec-12 2:05am
View
Mehdi Gholam thanks alot Sir
Member 9411249
24-Dec-12 1:57am
View
thnx
Member 9411249
24-Dec-12 1:57am
View
1)What is BaudRate and why we use 9600 not other?
2)If parity is for error checking then why we set Parity.None?
3)What is Databits?
4)What is Handshake do?
5)
Collapse | Copy Code
this.serialPort.WriteLine("AT" + (char)(13));// why we set char 13?
6)this.serialPort.WriteLine("AT+CMGF=1" + (char)(13));//also here char 13?
7)this.serialPort.WriteLine(">" + messages + (char)(26));//why we set char 26 here?
Member 9411249
24-Dec-12 1:46am
View
question in\\ after coding see
Member 9411249
3-Dec-12 8:48am
View
its not working its give error"Does not contain a definition for loadports and no extension methods" :(
Member 9411249
3-Dec-12 8:47am
View
its not working its give error"Does not contain a definition for loadports and no extension methods" :(
Member 9411249
21-Nov-12 9:30am
View
Thank you :)its work for me...
Member 9411249
21-Nov-12 9:15am
View
this is the Form2 opening a form3
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsAppDAL
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
Form3 f3 = new Form3();
private void timer1_Tick(object sender, EventArgs e)
{
if (progressBar2.Value < 100)
{
progressBar2.Value += 2;
}
else
{
timer1.Stop(); // Before calling f2.ShowDialog(), stops the timer event
Hide();
f3.ShowDialog();
Close();
}
//progressBar1.Increment(1);
}
}
}
this is the form3 opening a Form2
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsAppDAL
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void applicationToolStripMenuItem_Click(object sender, EventArgs e)
{
Form1 fm2 = new Form1();
fm2.Show();
}
}
}
my Application is in form2
Member 9411249
21-Nov-12 8:55am
View
Deleted
i am trying to say that when i load application with out using Splash Screen its work perfectly(Form1). But when i use that Form using Splash Screen(Form2) its not work perfectly.(means Form1 does not load perfectly
this the class to open or close ports
namespace SMS
{
class SmsClass
{
SerialPort serialPort;
public SmsClass(string comPort)
{
this.serialPort = new SerialPort();
this.serialPort.PortName = comPort;
this.serialPort.BaudRate = 9600;
this.serialPort.Parity = Parity.None;
this.serialPort.DataBits = 8;
this.serialPort.StopBits = StopBits.One;
this.serialPort.Handshake = Handshake.RequestToSend;
this.serialPort.DtrEnable = true;
this.serialPort.RtsEnable = true;
}
public bool sendSms(string cellNo, string sms)
{
string messages = null;
messages = sms;
if (this.serialPort.IsOpen == true)
{
try
{
this.serialPort.NewLine = System.Environment.NewLine;
this.serialPort.WriteLine("AT" + (char)(13));
Thread.Sleep(4);
this.serialPort.WriteLine("AT+CMGF=1" + (char)(13));
Thread.Sleep(5);
this.serialPort.WriteLine("AT+CMGS=\"" + cellNo + "\"");
Thread.Sleep(10);
this.serialPort.WriteLine(">" + messages + (char)(26));
}
catch (Exception ex)
{
//MessageBox.Show(ex.Source);
}
return true;
}
else
return false;
}
public void Opens()
{
if (this.serialPort.IsOpen == false)
{
this.serialPort.Open();
}
}
public void Closes()
{
if (this.serialPort.IsOpen == true)
{
this.serialPort.Close();
}
}
}
}
but when i try to open a 2nd form using 1st form this ports does not load
Member 9411249
20-Nov-12 2:05am
View
Thank you so much :)
Member 9411249
19-Nov-12 13:17pm
View
Hm thnx ED i will try
Member 9411249
18-Nov-12 13:33pm
View
Deleted
i have tried lot of things with code but that not enough for me
Member 9411249
18-Nov-12 13:27pm
View
here SMS class
namespace SMS
{
class SmsClass
{
SerialPort serialPort;
public SmsClass(string comPort)
{
this.serialPort = new SerialPort();
this.serialPort.PortName = comPort;
this.serialPort.BaudRate = 9600;
this.serialPort.Parity = Parity.None;
this.serialPort.DataBits = 8;
this.serialPort.StopBits = StopBits.One;
this.serialPort.Handshake = Handshake.RequestToSend;
this.serialPort.DtrEnable = true;
this.serialPort.RtsEnable = true;
}
public bool sendSms(string cellNo, string sms)
{
string messages = null;
messages = sms;
if (this.serialPort.IsOpen == true)
{
try
{
this.serialPort.NewLine = System.Environment.NewLine;
this.serialPort.WriteLine("AT" + (char)(13));
Thread.Sleep(4);
this.serialPort.WriteLine("AT+CMGF=1" + (char)(13));
Thread.Sleep(5);
this.serialPort.WriteLine("AT+CMGS=\"" + cellNo + "\"");
Thread.Sleep(10);
this.serialPort.WriteLine(">" + messages + (char)(26));
}
catch (Exception ex)
{
//MessageBox.Show(ex.Source);
}
return true;
}
else
return false;
}
public void Opens()
{
if (this.serialPort.IsOpen == false)
{
this.serialPort.Open();
}
}
public void Closes()
{
if (this.serialPort.IsOpen == true)
{
this.serialPort.Close();
}
}
}
}
Member 9411249
18-Nov-12 3:25am
View
i want that when i close form2 so form1 close automatically its not closed when i closed Form2?? help me plz
thnx
Member 9411249
18-Nov-12 2:58am
View
Thank you so much for helping me... :)
Member 9411249
18-Nov-12 2:57am
View
Thank you so much its work for me...:)
Member 9411249
18-Nov-12 2:45am
View
Thanx ED but this code sent msg only One Number(1st number of the loop) not other numbers
any idea what to do...?
Member 9411249
17-Nov-12 14:50pm
View
this gives me an error and not working means not open Form2
Show More