int kpad_scan_line( SCANINFO *sinfo, unsigned int i) { __u8 col, downkey, upkey; static __u8 row; unsigned int j; if (i == 0) row = 0x01; out_raw(~row); udelay(ROW_DELAY); in_col(&col); sinfo->key[i] = col; if (~(sinfo->key[i])) sinfo->push_flg = 1; sinfo->diffkey[i] = sinfo->key[i] ^ sinfo->lastkey[i]; if (sinfo->diffkey[i]) { downkey = ~sinfo->key[i] & sinfo->diffkey[i]; /* key went down */ upkey = sinfo->key[i] & sinfo->diffkey[i]; /* key went up */ for (j = 0, col=0x80; j < 8; j++, col >>= 1) { if (downkey & col) handle_scancode( KEYCODE(i, j), 1 ); else if ( upkey & col ) handle_scancode( KEYCODE(i, j) | KBUP, 0 ); } }
void main() { clrscr(); char pwd[]="bigmanani"; char ans[20]; cout<<"Enter password : "******"*"; } else break; } if(strcmp(ans,pwd)) { cout<<"\nIncorrect password."; getch(); exit(0); } int op; clrscr(); fout<<"main\n"; ifstream fin("sdk.txt"); // cout<<"Enter the puzzle row-wise (Use 0's for empty spaces) :\n"; for(int i=0;i<=8;++i) for(int j=0;j<=8;++j) { fin>>space[i][j].value; if(space[i][j].value==0) { for(int k=1;k<=9;++k) space[i][j].poss[k]=1; } else { for(int k=1;k<=9;++k) { if(k!=space[i][j].value) space[i][j].poss[k]=0; else space[i][j].poss[k]=1; } } } cout<<"Puzzle accepted. Starting Evaluation.\n"; //getch(); for(int e=1;;++e) { fout<<"Starting Evaluation "<<e<<"\n"; // getch(); for(i=0;i<=8;++i) { for(j=0;j<=8;++j) { int nop=0; cell_one_pos(i,j); int the_poss_val=0; cout<<"Evaluating space "<<i<<" "<<j<<"\n"; //getch(); if(space[i][j].value!=0) // already filled { cout<<"space "<<i<<" "<<j<<" is already filled.\n";//getch(); continue; } else cout<<"space "<<i<<" "<<j<<" is empty\n";//getch(); for(int k=1;k<=9;++k) { cout<<"Trying value "<<k<<"\n"; //getch (); if(!in_col(j,k)&&!in_row(i,k)&&!in_box(i,j,k)) // check conds { nop++; cout<<k<<" is a possible value.\n"; //getch(); space[i][j].poss[k]=1; the_poss_val=k; } else if(in_col(j,k)||in_row(i,k)||in_box(i,j,k)) { space[i][j].poss[k]=0; cout<<k<<" is not a possible value\n"; // getch(); } } if(nop==1) { space[i][j].value=the_poss_val; cout<<i<<" "<<j<<" ="<<the_poss_val<<"\n";// getch(); boxes_filled++; for(int d=1;d<=9;d++) { if(d!=the_poss_val) space[i][j].poss[d]=0; } } } } elim(0,0);elim(0,3);elim(0,6); elim(3,0);elim(3,3);elim(3,6); elim(6,0);elim(6,3);elim(6,6); rem_lin_pos(1133);rem_lin_pos(4769); rem_lin_pos(1436);rem_lin_pos(7193); rem_lin_pos(1739);rem_lin_pos(7496); rem_lin_pos(4163);rem_lin_pos(7799); rem_lin_pos(4466); cout<<"\nEvaluation "<<e<<" finished. A total of "<<boxes_filled<<" spaces have now been filled.\n"; Menu : cout<<"\n1.View the puzzle solved this far.\n"; cout<<"2.Continue Evaluation.\n"; cout<<"3.View the possibilities of a space. [row col]\n"; cout<<"4.Exit Program.\n"; cout<<"6.Elimination\n"; cout<<"7.Set Value. [row col val]\n"; cout<<"Choose an Option : "; cin>>op; if(op==1) { for(i=0;i<=8;++i) { for(j=0;j<=8;++j) { //if(space[i][j].value!=0) cout<<" "<<space[i][j].value; /* else { cout<<" {"; for(int g=1;g<=9;++g) { if(space[i][j].poss[g]) cout<<g; } cout<<"}"; } */ } cout<<"\n"; } } if(op==2) { unfilled(); continue; } if(op==3) { int i,j; cin>>i>>j; cout<<"Possibilities are : "; for(int k=1;k<=9;++k) { if(space[i][j].poss[k]==1) cout<<k<<" "; } } if(op==4) exit(0); if(op==5) { cout<<"Enter BIN : "; int bin; cin>>bin; double_down(bin); }