Click here to Skip to main content
15,899,935 members
Home / Discussions / C#
   

C#

 
QuestionKeep application settings on version change Pin
souren7726-Aug-09 14:09
souren7726-Aug-09 14:09 
AnswerRe: Keep application settings on version change Pin
Henry Minute26-Aug-09 14:41
Henry Minute26-Aug-09 14:41 
QuestionTyped Dataset replacing existing relationship for dynamic one throws: The row doesn't belong to the same DataSet as this relation [modified] Pin
Nohcs77726-Aug-09 13:53
Nohcs77726-Aug-09 13:53 
QuestionSQLCE C# Not Selecting New Records Pin
hobbsieoz26-Aug-09 11:11
hobbsieoz26-Aug-09 11:11 
QuestionClickOnce Update Problem Pin
MWRivera26-Aug-09 10:46
MWRivera26-Aug-09 10:46 
AnswerCross post Pin
Not Active26-Aug-09 10:58
mentorNot Active26-Aug-09 10:58 
QuestionUdpClient Error : Only one usage of each socket address (protocol/network address/port) is normally permitted PinPopular
zafersavas26-Aug-09 10:10
zafersavas26-Aug-09 10:10 
AnswerRe: UdpClient Error : Only one usage of each socket address (protocol/network address/port) is normally permitted Pin
stancrm26-Aug-09 13:05
stancrm26-Aug-09 13:05 
AnswerRe: UdpClient Error : Only one usage of each socket address (protocol/network address/port) is normally permitted Pin
N a v a n e e t h26-Aug-09 15:47
N a v a n e e t h26-Aug-09 15:47 
QuestionSpecial character ` in Visual Studio generated queries and how to remove it Pin
prg191226-Aug-09 9:58
prg191226-Aug-09 9:58 
AnswerRe: Special character ` in Visual Studio generated queries and how to remove it Pin
N a v a n e e t h26-Aug-09 15:49
N a v a n e e t h26-Aug-09 15:49 
GeneralRe: Special character ` in Visual Studio generated queries and how to remove it Pin
prg191227-Aug-09 11:15
prg191227-Aug-09 11:15 
QuestionC# Messenger Pin
I Believe In GOD26-Aug-09 9:51
I Believe In GOD26-Aug-09 9:51 
AnswerRe: C# Messenger Pin
DaveyM6926-Aug-09 10:11
professionalDaveyM6926-Aug-09 10:11 
GeneralRe: C# Messenger Pin
I Believe In GOD26-Aug-09 12:13
I Believe In GOD26-Aug-09 12:13 
GeneralRe: C# Messenger Pin
harold aptroot26-Aug-09 10:22
harold aptroot26-Aug-09 10:22 
GeneralRe: C# Messenger Pin
I Believe In GOD26-Aug-09 12:17
I Believe In GOD26-Aug-09 12:17 
GeneralRe: C# Messenger Pin
harold aptroot26-Aug-09 12:47
harold aptroot26-Aug-09 12:47 
AnswerRe: C# Messenger Pin
Patrick Eckler26-Aug-09 12:03
Patrick Eckler26-Aug-09 12:03 
GeneralRe: C# Messenger Pin
harold aptroot26-Aug-09 12:10
harold aptroot26-Aug-09 12:10 
AnswerRe: C# Messenger Pin
N a v a n e e t h26-Aug-09 16:02
N a v a n e e t h26-Aug-09 16:02 
GeneralRe: C# Messenger Pin
I Believe In GOD27-Aug-09 3:03
I Believe In GOD27-Aug-09 3:03 
QuestionProgrammatically import Access DB into SQL Express Pin
benford26-Aug-09 9:46
benford26-Aug-09 9:46 
QuestionSudoku problem [modified] Pin
GravityKoch26-Aug-09 9:45
GravityKoch26-Aug-09 9:45 
Hello guy´s

I´ve a problem with the implementation of Sudoku in c#....

i wrote 2 for-loops, one that tests the collums, one that tests the rows if the numbers 1-9 are unique in a row/col... The 2 Loops are working perfect, but only if i use ONE of them.. The 2 loops are not working together , I think it´s a Overflow...
I try to interlace the for-loops, but i´m with stupid.. I have to ask for help in this forum

here is a bit of code
using System;
using System.Collections.Generic;
using System.Text;

namespace sudoku
{
    class sudoku
    {
        private int[] values_right = new int[81];

        private int[] squareindex = new int[81] {0, 0, 0, 1, 1, 1, 2, 2, 2,
                                                 0, 0, 0, 1, 1, 1, 2, 2, 2,
                                                 0, 0, 0, 1, 1, 1, 2, 2, 2,
                                                 3, 3, 3, 4, 4, 4, 5, 5, 5,
                                                 3, 3, 3, 4, 4, 4, 5, 5, 5, 
                                                 3, 3, 3, 4, 4, 4, 5, 5, 5, 
                                                 6, 6, 6, 7, 7, 7, 8, 8, 8, 
                                                 6, 6, 6, 7, 7, 7, 8, 8, 8, 
                                                 6, 6, 6, 7, 7, 7, 8, 8, 8};

        private int[] posible_values = new int[9] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

        public sudoku()
        {
            this.generate();
        }

        public void generate()
        {
            /*
            int[] values = {8, 4, 6, 3, 5, 1, 7, 9, 2, 
                            5, 1, 3, 9, 2, 7, 4, 6, 8, 
                            7, 9, 2, 6, 8, 4, 1, 3, 5,
                            4, 3, 8, 5, 7, 9, 6, 2, 1, 
                            1, 7, 9, 2, 4, 6, 5, 8, 3, 
                            2, 6, 5, 8, 1, 3, 9, 7, 4, 
                            6, 8, 1, 7, 3, 5, 2, 4, 9, 
                            9, 2, 4, 1, 6, 8, 3, 5, 7, 
                            3, 5, 7, 4, 9, 2, 8, 1, 6};
            */


            Random rnd = new Random();
            int i;
           


            for (i = 0; i < 81; i++)
            {
                while (this.values_right[i] == 0)
                    this.values_right[i] = rnd.Next(1, 90) % 10;


                while (check_position(i) == 0)
                {
                    this.values_right[i] = (this.values_right[i] + 1) % 10;

                }
            }

        }

        public int[] get_values_right()
        {
            return values_right;
        }

        int check_position(int i)
        {
            if (this.values_right[i] == 0)
                return 0;

            Random rnd = new Random();
            int row = i - (i % 9);
            int col = i % 9;
            int position;

             for (position = row; position < row + 9; position++)
            {
                if (position == i)
                    continue;

                if (this.values_right[position] == this.values_right[i])
                    return 0;
            }

           /*for (position = col; position < 80; position += 9)
            {
                if (position == i)
                    continue;

                if (this.values_right[position] == this.values_right[i])
                    return 0;
            }*/


            return 1;
        }
    }
}




Thanks for help, members of coding...
I´m sure, its only a LITTLE 1-MINUTE problem 4 you..

Thank again..^^

modified on Thursday, August 27, 2009 2:25 AM

AnswerRe: Sudoku problem Pin
EliottA26-Aug-09 11:21
EliottA26-Aug-09 11:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.