Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help::i have made a sudoku solver but it not workin

Help::i have made a sudoku solver but it not workin

Scheduled Pinned Locked Moved C / C++ / MFC
help
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    keshava shukla
    wrote on last edited by
    #1

    // :doh:hey here goes the program i have made pls help me out to find errors #include //#include #include #include #include class sudoku{ int a[9][9][10],count; public: sudoku(); void initsudoku(); void redprob(int , int); void dispsudoku(); void fillele(int , int ); void fillsudoku(); } ; sudoku::sudoku() { int i , j ,k; count=81; cout<<"constructor"; for( i=1;i<=9;i++) for ( j=1;j<=9;j++){ a[i][j][0]=99; for ( k=1;k<=9;k++) a[i][j][k]=0; a[i][j][10]=9; } } void sudoku::redprob(int i, int j ) { int k,l,temp; temp=a[i][j][0]; for ( k=1;k<=9;k++) { if (( k!=j) && (a[i][k][temp]!=99)); { a[i][k][temp] = 99; a[i][k][10]--; if(a[i][k][10]==1) fillele(i,k); } if (( k!=i)&&(a[k][j][temp]!=99)); { a[k][j][temp] = 99; a[k][j][10]--; if(a[k][j][10]==1) fillele(k,j); } } cout<<"l"<>i; cout<<"column no."; cin>>j; cout<<"enter value"; cin>>val; if ((i<=9)&&(j<=9)&&(a[i][j][val]==0)&&(count<=0)) { a[i][j][0]=val; a[i][j][10]=0; count--; redprob(i,j); } else if (i>9) cout<<"wrong row value"; else if (j>9) cout<<"wrong column value"; else if (count<=0) cout<<"already 81 elements have been identified"; else cout<<" you can not place this value here"; cout<<"enter any other element "; cin>>ch; } } void sudoku::fillele(int i, int j ) { for( int k=1; k<=9;k++) if( a[i][j][k] == 0){ a[i][j][0] = k; a[i][j][10]=0; count--; redprob(i,j); } } void sudoku::dispsudoku() { int i,j; for( i=1;i<=9;i++) { for ( j=1;j<=9;j++){ if(a[j][i][0]>10){ cout<<" "; } else { cout<

    D C 2 Replies Last reply
    0
    • K keshava shukla

      // :doh:hey here goes the program i have made pls help me out to find errors #include //#include #include #include #include class sudoku{ int a[9][9][10],count; public: sudoku(); void initsudoku(); void redprob(int , int); void dispsudoku(); void fillele(int , int ); void fillsudoku(); } ; sudoku::sudoku() { int i , j ,k; count=81; cout<<"constructor"; for( i=1;i<=9;i++) for ( j=1;j<=9;j++){ a[i][j][0]=99; for ( k=1;k<=9;k++) a[i][j][k]=0; a[i][j][10]=9; } } void sudoku::redprob(int i, int j ) { int k,l,temp; temp=a[i][j][0]; for ( k=1;k<=9;k++) { if (( k!=j) && (a[i][k][temp]!=99)); { a[i][k][temp] = 99; a[i][k][10]--; if(a[i][k][10]==1) fillele(i,k); } if (( k!=i)&&(a[k][j][temp]!=99)); { a[k][j][temp] = 99; a[k][j][10]--; if(a[k][j][10]==1) fillele(k,j); } } cout<<"l"<>i; cout<<"column no."; cin>>j; cout<<"enter value"; cin>>val; if ((i<=9)&&(j<=9)&&(a[i][j][val]==0)&&(count<=0)) { a[i][j][0]=val; a[i][j][10]=0; count--; redprob(i,j); } else if (i>9) cout<<"wrong row value"; else if (j>9) cout<<"wrong column value"; else if (count<=0) cout<<"already 81 elements have been identified"; else cout<<" you can not place this value here"; cout<<"enter any other element "; cin>>ch; } } void sudoku::fillele(int i, int j ) { for( int k=1; k<=9;k++) if( a[i][j][k] == 0){ a[i][j][0] = k; a[i][j][10]=0; count--; redprob(i,j); } } void sudoku::dispsudoku() { int i,j; for( i=1;i<=9;i++) { for ( j=1;j<=9;j++){ if(a[j][i][0]>10){ cout<<" "; } else { cout<

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      keshava shukla wrote:

      pls help me out to find errors

      It's actually up to you to find the error(s). Narrow the problem down to just a few lines of code, and then you're bound to get lots of help. No one is going to wade through a bunch of code to find something that you should be finding.


      "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

      "Judge not by the eye but by the heart." - Native American Proverb

      1 Reply Last reply
      0
      • K keshava shukla

        // :doh:hey here goes the program i have made pls help me out to find errors #include //#include #include #include #include class sudoku{ int a[9][9][10],count; public: sudoku(); void initsudoku(); void redprob(int , int); void dispsudoku(); void fillele(int , int ); void fillsudoku(); } ; sudoku::sudoku() { int i , j ,k; count=81; cout<<"constructor"; for( i=1;i<=9;i++) for ( j=1;j<=9;j++){ a[i][j][0]=99; for ( k=1;k<=9;k++) a[i][j][k]=0; a[i][j][10]=9; } } void sudoku::redprob(int i, int j ) { int k,l,temp; temp=a[i][j][0]; for ( k=1;k<=9;k++) { if (( k!=j) && (a[i][k][temp]!=99)); { a[i][k][temp] = 99; a[i][k][10]--; if(a[i][k][10]==1) fillele(i,k); } if (( k!=i)&&(a[k][j][temp]!=99)); { a[k][j][temp] = 99; a[k][j][10]--; if(a[k][j][10]==1) fillele(k,j); } } cout<<"l"<>i; cout<<"column no."; cin>>j; cout<<"enter value"; cin>>val; if ((i<=9)&&(j<=9)&&(a[i][j][val]==0)&&(count<=0)) { a[i][j][0]=val; a[i][j][10]=0; count--; redprob(i,j); } else if (i>9) cout<<"wrong row value"; else if (j>9) cout<<"wrong column value"; else if (count<=0) cout<<"already 81 elements have been identified"; else cout<<" you can not place this value here"; cout<<"enter any other element "; cin>>ch; } } void sudoku::fillele(int i, int j ) { for( int k=1; k<=9;k++) if( a[i][j][k] == 0){ a[i][j][0] = k; a[i][j][10]=0; count--; redprob(i,j); } } void sudoku::dispsudoku() { int i,j; for( i=1;i<=9;i++) { for ( j=1;j<=9;j++){ if(a[j][i][0]>10){ cout<<" "; } else { cout<

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Even if you posted this properly ( checked 'ignore HTML tags' ), no-one is going to fix your program for you. Work out which bit is not doing what you expect, post a relevant code snippet and ask specific questions.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups