Friday, November 9, 2007

Sunday, July 15, 2007

a dos dummy ...... just made for fun

a dos dummy ...... just made for fun


/*commands cd - change directory
md - make directory
mf - make file
show - show file contents
dos - run dos commands
dir - show dirctory and file listing
*/
#include"stdio.h"
#include"conpsl"
#include"stdlib.h"
typedef struct
{char name[16];
char *info;
struct file *next;
}file;
typedef struct
{
char name[16];
struct folder *next;
struct folder *in;
struct folder *up;
struct file *fil;
}folder;
void print(char* c)
{
int i=0;
while(1)
{
if(c[i]==0)
break;
if(c[i]=='\r')
printf("\n");
else
printf("%c",c[i]);
i++;
}
}

char *content()
{
char *c,a;
int i=0;
c=(char*)malloc(sizeof(char)*3);
c[i]=0;
while(1)
{
a=getch();
if(a==26)
break;
else
{
if(c[i]!='\n'&&c[i]!='\r')
c[i]=a;
else
c[i]='\r';
if(c[i]!='\n'&&c[i]!='\r')
putch(c[i]);
else
printf("\n");
i++;
c=(char*)realloc(c,sizeof(c)*(i+2));
c[i]=0;
}
}
return c;
}


int main()
{char command[10],chek[16],*c;
int i=0,d=0,f=0;
folder *first,*p,*cur,*t;
file *fi;
print("puneet is cool \n");
first=(folder*)malloc(sizeof(folder));
first->name[0]=0;
strcat(first->name,"pslos");
first->next=0;
first->in=0;
first->fil=0;
first->up=0;
cur=first;
while(1)
{p=cur;
while(p->up!=0)
{
printf("%s",p->name);
p=(folder*)p->up;
printf(" <- ");
}
printf("%s",p->name);
printf(" :> ");
gets(command);


if(strcmp(command,"dir")==0)
{
printf("\n");
p=(folder*)cur->in;
d=0;
if(p!=0)
while(p!=0)
{
printf("(dir) %s\n",p->name);
p=(folder*)p->next;
d=d+1;
}

fi=(file*)cur->fil;
f=0;
if(fi!=0)
while(fi!=0)
{
printf(" %s\n",fi->name);
fi=(file*)fi->next;
f=f+1;
}
printf("\n");
printf("Total number of directories = %d \nand files = %d\n\n",d,f);
}


else if(strcmp(command,"show")==0)
{
printf("enter files's name : ");
gets(chek);
fi=(file*)cur->fil;
while(1)
{
if(fi->next==0)
break;
if(strcmp(chek,fi->name)==0)
break;
fi=(file*)fi->next;
}
if(strcmp(chek,fi->name)==0)
{print(fi->info);
print("\n");}
else
printf("File not found\n");
}



else if(strcmp(command,"md")==0)
{
if(cur->in==0)
{
(folder*)cur->in=(folder*)malloc(sizeof(folder));
p=(folder*)cur->in;
printf("enter folder's name : ");
gets(p->name);
p->next=0;
(folder*)p->up=cur;
p->fil=0;
p->in=0;
}
else
{
p=(folder*)cur->in;
while(p->next!=0)
{p=(folder*)p->next;}
(folder*)p->next=(folder*)malloc(sizeof(folder));
p=(folder*)p->next;
printf("enter folder's name : ");
gets(p->name);
p->next=0;
(folder*)p->up=(folder*)cur;
p->fil=0;
p->in=0;
}
}

else if(strcmp(command,"cd")==0)
{
printf("enter folder's name : ");
gets(chek);
p=(folder*)cur->in;
if(p!=NULL)
{
if(strcmp(chek,"..")==0)
{
if(cur->up!=0)
cur=(folder*)cur->up;
}
else
{
while(1)
{
if(p->next==0)
break;
if(strcmp(chek,p->name)==0)
break;
p=(folder*)p->next;
}
if(strcmp(chek,p->name)==0)
cur=p;
}
}
else
{
if(strcmp(chek,"..")==0)
{
if(cur->up!=0)
cur=(folder*)cur->up;
else
printf("no super folder to this folder exists !!!\n");
}
else if(p==NULL)
printf("no folder with this name exists in this directory !!!\n");
}
}


else if(strcmp(command,"mf")==0)
{
if(cur->fil==0)
{
(file*)cur->fil=(file*)malloc(sizeof(file));
fi=(file*)cur->fil;
printf("enter file's name : ");
gets(fi->name);
printf("enter contents of file :\n");
fi->info=content();
fi->next=0;
}
else
{
fi=(file*)cur->fil;
while(fi->next!=0)
{fi=(file*)fi->next;}
(file*)fi->next=(file*)malloc(sizeof(file));
(file*)fi=(file*)fi->next;
printf("enter file's name : ");
gets(fi->name);
printf("enter contents of file :\n");
fi->info=content();
fi->next=0;
}
}


else if(strcmp(command,"quit")==0)
{
printf("bye - bye ! see you next time");
getch();
exit(1);
}
else if(strcmp(command,"dos")==0)
{
printf("enter the dos command : ");
gets(command);
system(command);
}
else if(strcmp(command,"clear")==0)
{
system("cls");
}
else printf("command not found\n");
}
getch();
return 0;
}

Thursday, July 12, 2007

google searcher in c language.......you will surely like it ... and you can also see implimentation of "stringcat" function

#include "windows.h"
#include"stdio.h"
#include"conio.h"
#include"string.h"
#include"stdlib.h"
int main()
{
int i,j,k=0,l=0;
char a[34]="http://www.google.co.in/search?q=",b[50],c[200]="&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official",s[500];
system("color f0");
printf("\t\t\t~* google searcher *~\nenter any word to search in google::>");

gets(b);
for(i=0;i<33;i++)
{s[i]=a[i];}
for(i=33;;i++)
{if(b[l]!='\0')
s[i]=b[l];
else break;
l++;}

for(j=i;;j++)
{if(c[k]!='\0')
s[j]=c[k];
else break;
k++;}
s[j]='\0';

ShellExecute(0,0,s, NULL, NULL, 0);
MessageBox(0,"Psl corp. India\ntruly ultimate\n\nclick ok to exit","made by Puneet Singh ::::: batch b6 ::::: jiit",MB_OKCANCEL);
return 0;
}

Sudoku..... I think you will like to develop it... i didnt like the algorithm i've used .... please help me to develop it through a good algorithm


Your help is highly appriciated
//I made this software in dev c++ so some of its features will not work in turbo c3
//i am making it open source so that you also can help me to develop it further
/* if u r not able to use conio in dev c++ please do one thing copy turboc's conio.h to include folder of dev c++ and then in compiler options in dev c++ add conio.o's path...for more info visit ~~~ http://www.bloodshed.net/faq.html ~~~ faq no 12*/
#include"conio.h"
#include"stdio.h"

#include "stat.h"
#include "fcntl.h"
typedef struct{
int mat[9][9];
int col[9][9];}play;
int main(int argc,char *argv[])
{FILE *f;
play info,out;
int h,i,j,r,b,su=0,chk=0,q,w,l,k=0,sud[9][9],value,key,choice,val2,help=0,du1,du2,save[9][9],gothelp[27]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},checker[9]={1,2,3,4,5,6,7,8,9};
int tem[9][9][9]={9,0,0,4,0,0,0,6,0,7,0,0,0,2,0,9,0,0,0,5,8,0,0,9,0,0,0,0,6,0,0,3,2,1,7,0,0,0,0,0,5,0,0,0,0,0,8,3,6,1,0,0,2,0,0,0,0,2,0,0,8,5,0,0,0,2,0,9,0,0,0,6,0,1,0,0,0,8,0,0,7,/*1*/
0,0,2,6,0,7,9,0,0,0,0,0,9,0,8,0,0,0,9,3,0,0,0,0,0,2,6,0,0,4,5,0,3,2,0,0,0,1,0,0,0,0,0,4,0,0,0,5,8,0,2,6,0,0,1,4,0,0,0,0,0,9,2,0,0,0,4,0,6,0,0,0,0,0,7,2,0,1,3,0,0,/*2*/
0,0,0,0,3,7,0,8,0,9,0,0,0,8,0,3,0,5,0,0,1,0,0,0,0,0,0,7,0,0,0,5,1,6,0,0,2,0,0,7,0,4,0,0,3,0,0,3,9,2,0,0,0,1,0,0,0,0,0,0,9,0,0,3,0,4,0,9,0,0,0,6,0,2,0,4,1,0,0,0,0,/*3*/
0,0,0,7,0,4,0,0,0,0,0,8,0,2,0,4,0,0,3,0,9,0,0,0,5,0,7,0,0,6,2,0,1,8,0,0,0,7,0,0,0,0,0,9,0,0,0,4,8,0,5,2,0,0,4,0,3,0,0,0,6,0,2,0,0,7,0,8,0,3,0,0,0,0,0,6,0,9,0,0,0,/*4*/
0,8,0,2,0,6,0,7,0,0,0,5,0,0,0,2,0,0,4,2,0,0,0,0,0,8,3,0,0,0,7,3,8,0,0,0,9,0,0,0,0,0,0,0,8,0,0,0,4,9,2,0,0,0,1,4,0,0,0,0,0,3,9,0,0,8,0,0,0,4,0,0,0,3,0,8,0,7,0,6,0,/*5*/
0,0,6,0,3,0,0,5,0,3,0,0,0,0,8,6,0,1,0,5,1,6,0,0,0,0,0,0,1,8,4,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,9,1,3,0,0,0,0,0,0,7,2,6,0,8,0,4,1,0,0,0,0,3,0,3,0,0,8,0,7,0,0,/*6*/
0,0,6,4,0,8,0,3,5,0,0,0,9,0,0,8,0,1,0,0,0,0,7,6,0,0,0,0,3,0,0,0,0,1,0,6,0,0,7,0,0,0,4,0,0,8,0,9,0,0,0,0,5,0,0,0,0,5,9,0,0,0,0,3,0,8,0,0,2,0,0,0,5,4,0,1,0,3,6,0,0,/*7*/
0,1,0,0,7,3,0,8,0,8,0,3,0,0,0,0,0,5,0,2,0,4,0,0,0,0,0,1,9,0,0,0,0,0,0,2,0,0,7,2,0,1,6,0,0,5,0,0,0,0,0,0,4,3,0,0,0,0,0,4,0,1,0,3,0,0,0,0,0,9,0,7,0,6,0,8,9,0,0,2,0,/*8*/
1,0,0,0,0,7,0,9,0,0,3,0,0,2,0,0,0,8,0,0,9,6,0,0,5,0,0,0,0,5,3,0,0,9,0,0,0,1,0,0,8,0,0,0,2,6,0,0,0,0,4,0,0,0,3,0,0,0,0,0,0,1,0,0,4,0,0,0,0,0,0,7,0,0,7,0,0,0,3,0,0/*9*/};
char name[50],ext[5]=".sud";
begi:
clrscr();
textcolor(15);
if(argv[1]!=NULL)
goto playn;
gotoxy(50,1);
gotoxy(20,19);
printf("To check your solution press 1");
gotoxy(20,20);
printf("To play with computer press 2");
gotoxy(10,21);
printf("To play from a saved file press 3 - full editor mode");
gotoxy(4,22);
printf("To play from a psl corp sudoku puzzel file press 4 - restricted mode");

printf("\n");
choice=getch();
clrscr();

switch(choice-48)
{case 1:
// checking solution of given sudoku answer
printf("you have chosen to check your sudoku solution from any external source is correct or not\nI hope your solution is correct\nGoodluck!!");
getch();
clrscr();
for(i=0;i<9;i++)
for(j=0;j<9;j++)
{sud[i][j]=0;
//assigning values
}
//first printing of sudoku
printf("\n\t\t use arrow key to move cursor\n\t\t press 'c' to chek your solution\n\n");
printf("\t\t +-----------------------+\n");
for(i=0;i<9;i++)
{for(j=0;j<9;j++)
{if(j%9==0)
printf("\t\t | ");
printf("%d ",sud[i][j]);
if((j+1)%3==0)
printf("| ");}
printf("\n");
if((i+1)%3==0)
printf("\t\t +-----------------------+\n");}
//printing ends


//now insertion of matrix values from user
for(i=0;i<9;i++)
{for(j=0;j<9;j++)
{value=getch();//get the input from user

if(value==224||value==0)
{val2=getch();
//forward move
if(val2==77)
{ if(j==8)
j=j-1;
k=0; }
//backward move
if(val2==75)
{
if(j==0)
j=j-1;
else if(j>0)
j=j-2;
k=0;
}
//up movement
if(val2==72)
{ if(i>0)
i=i-1;
j=j-1;
k=0;
}
//down movement
if(val2==80)
{ if(i<8)
i=i+1;
j=j-1;
k=0;
}


}
//quit
else
if(value=='c')
{goto out;}
//insertion of numbers
else
if(value-48>0&&value-48<=9)
{
sud[i][j]=value-48;
k=0;}
else
{k=1;
j=j-1;}
//printing of sudoku showing with moving cursor
if(i==8&&j==8)
j=j-1;
clrscr();
printf("\n\t\t use arrow key to move cursor\n\t\t press 'c' to chek your solution\n\n");
printf("\t\t +-----------------------+\n");
for(q=0;q<9;q++)
{for(w=0;w<9;w++)
{if(w%9==0)
printf("\t\t | ");
if(q==(i)&&w==(j+1))
printf("/ ");
else
printf("%d ",sud[q][w]);
if((w+1)%3==0)
printf("| ");}
printf("\n");
if((q+1)%3==0)
printf("\t\t +-----------------------+\n");}
printf("\t\t current value at your cursor position:%d",sud[i][j+1]);
if(k!=0)
printf("\ninvalid value!!\nplease try again with diffrent value");
//printing ends

}
}
break;

case 2:
case2:
clrscr();

// checking solution of given sudoku answer
printf("you have chosen to play sudoku\ni know this would be tough\nBut I hope you will play fine\nchoose a number from 1-9 to choose one sudoku \nRemember as the nuber increases sudoku will become tougher to solve\nmake your choice:\n");
rep:
key=getch();
if(key-48<=0||key-48>9)
{printf("invalid!! try again\n");
goto rep; }


clrscr();
for(i=0;i<9;i++)
for(j=0;j<9;j++)
{
sud[i][j]=tem[key-49][i][j];
info.mat[i][j]=tem[key-49][i][j];
if(tem[key-49][i][j]==0)
info.col[i][j]=15;
else
info.col[i][j]=12;

//assigning values
}
//first printing of sudoku
printf("\n\t\t use arrow key to move cursor\n\t\t press 'c' to chek your solution\n\t\t press 'x' for help \npress 's' to save your current sudoku positions to play in future\n\n");
printf("\t\t +-----------------------+\n");
for(i=0;i<9;i++)
{for(j=0;j<9;j++)
{if(j%9==0)
printf("\t\t | ");
printf("%d ",sud[i][j]);
if((j+1)%3==0)
printf("| ");}
printf("\n");
if((i+1)%3==0)
printf("\t\t +-----------------------+\n");}
//printing ends


//now insertion of matrix values from user
for(i=0;i<9;i++)
{for(j=0;j<9;j++)
{value=getch();//get the input from user

if(value==224||value==0)
{val2=getch();
//forward move
if(val2==77)
{ if(j==8)
j=j-1;
k=0; }
//backward move
if(val2==75)
{
if(j==0)
j=j-1;
else if(j>0)
j=j-2;
k=0;
}
//up movement
if(val2==72)
{ if(i>0)
i=i-1;
j=j-1;
k=0;
}
//down movement
if(val2==80)
{ if(i<8)
i=i+1;
j=j-1;
k=0;
}


}
//quit
else
if(value=='c')
{goto out;}
else
if(value=='s')
{printf("\ngive a name to the file:");
gets(name);
strcat(name,ext);
f=fopen(name,"w");
fwrite(&info,sizeof(info),1,f);
fclose(f);
printf("\nfile saved!!");
getch();
j=j-1;}
else
if(value=='x')
{if(tem[key-49][i][j]==0)
{help=1;
du1=i;
du2=j;
goto out;
helpend:
help=0;
j=j-1;}
else
{k=2;
j=j-1;}}
//insertion of numbers
else
if(value-48>=0&&value-48<=9)
{if(tem[key-49][i][j]==0)
{sud[i][j]=value-48;
info.mat[i][j]=value-48;
k=0;}
else
k=2;
if(j==8)
j=j-1;}
else
{k=1;
j=j-1;}
//printing of sudoku showing with moving cursor
if(i==8&&j==8)
j=j-1;
clrscr();
printf("\n\t\t use arrow key to move cursor\n\t\t press 'c' to chek your solution\n\t\t press 'x' for help\npress 's' to save your current sudoku positions to play in future\n\n");
printf("\t\t +-----------------------+\n");
for(q=0;q<9;q++)
{for(w=0;w<9;w++)
{if(w%9==0)
printf("\t\t | ");
if(q==(i)&&w-1==(j))
{textcolor(176);
printf("%d",sud[q][w]);
textcolor(0);
printf(" ");
textcolor(15);}
else
{if(tem[key-49][q][w]==0)
{textcolor(15);
printf("%d ",sud[q][w]);}
else
{textcolor(12);
printf("%d ",sud[q][w]);}
textcolor(15);
}
if((w+1)%3==0)
printf("| ");}
printf("\n");
if((q+1)%3==0)
printf("\t\t +-----------------------+\n");}
printf("\t\t current value at your cursor position:%d",sud[i][j+1]);
if(k==1)//error no 1
printf("\ninvalid value!!\nplease try again with diffrent value");
if(k==2)//error no 2
printf("\nThis value is basic and cannot be changed!!\nBecause it is assigned by the computer ");

//printing ends

}




}
break;
case 3:
// checking solution of given sudoku answer
playn:
if(argv[1]!=0)
{
f=fopen(argv[1],"r");
goto conti;
}
printf("you have chosen to play sudoku by openinig a file\n");
puts("enter file path which u want to open:");
gets(name);
strcat(name,ext);
f=fopen(name,"r");
conti:
if(f==NULL)
{puts("\nCannot open source file!! sorry\nBut still you can play from our 9 sudoku puzzels");
getch();
goto case2;}
else
{
if(argv[1]==0)
puts("file opened!!");
fread(&out,sizeof(out),1,f);
fclose(f);
if(argv[1]==0)
{printf("press any key to continue....");
getch();
}}
clrscr();
for(i=0;i<9;i++)
for(j=0;j<9;j++)
{
sud[i][j]=out.mat[i][j];
//assigning values
}
//first printing of sudoku
printf("\n\t\t use arrow key to move cursor\n\t\t press 'c' to chek your solution\n\t\t press 'x' for help \npress 's' to save your current sudoku positions to play in future\n\n");
printf("\t\t +-----------------------+\n");
for(i=0;i<9;i++)
{for(j=0;j<9;j++)
{if(j%9==0)
printf("\t\t | ");
printf("%d ",sud[i][j]);
if((j+1)%3==0)
printf("| ");}
printf("\n");
if((i+1)%3==0)
printf("\t\t +-----------------------+\n");}
//printing ends


//now insertion of matrix values from user
for(i=0;i<9;i++)
{for(j=0;j<9;j++)
{value=getch();//get the input from user

if(value==224||value==0)
{val2=getch();
//forward move
if(val2==77)
{ if(j==8)
j=j-1;
k=0; }
//backward move
if(val2==75)
{
if(j==0)
j=j-1;
else if(j>0)
j=j-2;
k=0;
}
//up movement
if(val2==72)
{ if(i>0)
i=i-1;
j=j-1;
k=0;
}
//down movement
if(val2==80)
{ if(i<8)
i=i+1;
j=j-1;
k=0;
}


}
//quit
else
if(value=='c')
{goto out;}
else
if(value=='s')
{printf("\ngive a name to the file:");
gets(name);
strcat(name,ext);
f=fopen(name,"w");
fwrite(&out,sizeof(out),1,f);
fclose(f);
printf("\nfile saved!!");
getch();
j=j-1;}
else
if(value=='x')
{if(out.col[i][j]!=12)
{help=1;
du1=i;
du2=j;
goto out;
helpend2:
help=0;
j=j-1;}
else
{k=2;
j=j-1;}}
//insertion of numbers
else
if(value-48>=0&&value-48<=9)
{
if(out.col[i][j]!=12)
{sud[i][j]=value-48;
out.mat[i][j]=value-48;
k=0;}
else
k=2;
if(j==8)
j=j-1;}
else
k=1;
//printing of sudoku showing with moving cursor
if(i==8&&j==8)
j=j-1;
clrscr();
printf("\n\t\t use arrow key to move cursor\n\t\t press 'c' to chek your solution\n\t\t press 'x' for help\npress 's' to save your current sudoku positions to play in future\n\n");
printf("\t\t +-----------------------+\n");
for(q=0;q<9;q++)
{for(w=0;w<9;w++)
{if(w%9==0)
printf("\t\t | ");
if(q==(i)&&w-1==(j))
{textcolor(176);
printf("%d",sud[q][w]);
textcolor(0);
printf(" ");
textcolor(15);}
else
{
textcolor(out.col[q][w]);
printf("%d ",sud[q][w]);
textcolor(15);
}
if((w+1)%3==0)
printf("| ");}
printf("\n");
if((q+1)%3==0)
printf("\t\t +-----------------------+\n");}
printf("\t\t current value at your cursor position:%d\n",sud[i][j+1]);
if(k==1)//error no 1
printf("\ninvalid value!!\nplease try again with diffrent value");
if(k==2)//error no 2
printf("\nThis value is basic and cannot be changed!!\nBecause it is assigned by the computer ");

//printing ends

}




}
break;
case 4:
// checking solution of given sudoku answer
printf("you have chosen to play sudoku by openinig a file\n");
puts("enter file path which u want to open:");
strcat(name,".sudpsl");
puts(name);
f=fopen(name,"r");
if(f==NULL)
{puts("\ncannot open source file!! sorry\nBut still you can play from our 9 sudoku puzzels\n");
getch();
goto case2;}
else
{puts("file opened");
fread(save,sizeof(save),1,f);
fclose(f);
printf("press any ket to continue....");}
getch();


clrscr();
for(i=0;i<9;i++)
for(j=0;j<9;j++)
{
sud[i][j]=save[i][j];

//assigning values
}
//first printing of sudoku
printf("\n\t\t use arrow key to move cursor\n\t\t press 'c' to chek your solution\n\t\t press 'x' for help \npress 's' to save your current sudoku positions to play in future\n\n");
printf("\t\t +-----------------------+\n");
for(i=0;i<9;i++)
{for(j=0;j<9;j++)
{if(j%9==0)
printf("\t\t | ");
printf("%d ",sud[i][j]);
if((j+1)%3==0)
printf("| ");}
printf("\n");
if((i+1)%3==0)
printf("\t\t +-----------------------+\n");}
//printing ends


//now insertion of matrix values from user
for(i=0;i<9;i++)
{for(j=0;j<9;j++)
{value=getch();//get the input from user

if(value==224||value==0)
{val2=getch();
//forward move
if(val2==77)
{ if(j==8)
j=j-1;
k=0; }
//backward move
if(val2==75)
{
if(j==0)
j=j-1;
else if(j>0)
j=j-2;
k=0;
}
//up movement
if(val2==72)
{ if(i>0)
i=i-1;
j=j-1;
k=0;
}
//down movement
if(val2==80)
{ if(i<8)
i=i+1;
j=j-1;
k=0;
}


}
//quit
else
if(value=='c')
{goto out;}
else
if(value=='s')
{printf("\ngive a name to the file:");
gets(name);
f=fopen(name,"w");
fwrite(&info,sizeof(info),1,f);
fclose(f);
printf("\nfile saved!!");
getch();
j=j-1;}
else
if(value=='x')
{if(save[i][j]==0)
{help=1;
du1=i;
du2=j;
goto out;
helpend3:
help=0;
j=j-1;}
else
{k=2;
j=j-1;}}
//insertion of numbers
else
if(value-48>=0&&value-48<=9)
{if(save[i][j]==0)
{sud[i][j]=value-48;
k=0;}
else
k=2;
if(j==8)
j=j-1;}
else
{k=1;
j=j-1;}
//printing of sudoku showing with moving cursor
if(i==8&&j==8)
j=j-1;
clrscr();
printf("\n\t\t use arrow key to move cursor\n\t\t press 'c' to chek your solution\n\t\t press 'x' for help\npress 's' to save your current sudoku positions to play in future\n\n");
printf("\t\t +-----------------------+\n");
for(q=0;q<9;q++)
{for(w=0;w<9;w++)
{if(w%9==0)
printf("\t\t | ");
if(q==(i)&&w-1==(j))
printf("/ ");
else
{if(save[q][w]==0)
{textcolor(15);
printf("%d ",sud[q][w]);}
else
{textcolor(12);
printf("%d ",sud[q][w]);}
textcolor(15);
}
if((w+1)%3==0)
printf("| ");}
printf("\n");
if((q+1)%3==0)
printf("\t\t +-----------------------+\n");}
printf("\t\t current value at your cursor position:%d\n",sud[i][j+1]);
printf("\t\tearlier value taken from file at this position:%d\n",save[i][j+1]);
if(k==1)//error no 1
printf("\ninvalid value!!\nplease try again with diffrent value");
if(k==2)//error no 2
printf("\nThis value is basic and cannot be changed!!\nBecause it is assigned by the computer ");

//printing ends

}
}
break;


default:
printf("not a valid choice !! try again !!");
getch();
goto begi;
break;
}
out:

//here help starts
if(help!=0)
{//checking part started
//horizontal checking
su=0;
for(h=0;h<9;h++) //j from i+1 because to avoid self comparision
{if(sud[du1][h]!=0)
{gothelp[su]=sud[du1][h];
su=su+1;
}
}
//vertical checking
for(h=0;h<9;h++) //j from i+1 because to avoid self comparision
{if(sud[h][du2]!=0)
{gothelp[su]=sud[h][du2];
su=su+1;
}
}




//box checking ie. checking each box

//case 1: when elment is 0,0 ...
if((du1+1)%3==1&&(du2+1)%3==1)
{
gothelp[su]=sud[du1+1][du2+1];
su=su+1;
gothelp[su]=sud[du1+1][du2+2];
su=su+1;
gothelp[su]=sud[du1+2][du2+1];
su=su+1;
gothelp[su]=sud[du1+2][du2+2];
su=su+1;
}
//case 2: element 0,1..
if(du1%3==0&&du2%3==1)
{
gothelp[su]=sud[du1+1][du2-1];
su=su+1;
gothelp[su]=sud[du1+1][du2+1];
su=su+1;
gothelp[su]=sud[du1+2][du2-1];
su=su+1;
gothelp[su]=sud[du1+2][du2+1];
su=su+1;
}
//case 3: element 0,2..
if(du1%3==0&&du2%3==2)
{
gothelp[su]=sud[du1+1][du2-2];
su=su+1;
gothelp[su]=sud[du1+1][du2-1];
su=su+1;
gothelp[su]=sud[du1+2][du2-2];
su=su+1;
gothelp[su]=sud[du1+2][du2-1];
su=su+1;
}
if(du1%3==1&&du2%3==0)
{
gothelp[su]=sud[du1-1][du2+1];
su=su+1;
gothelp[su]=sud[du1-1][du2+2];
su=su+1;
gothelp[su]=sud[du1+1][du2+1];
su=su+1;
gothelp[su]=sud[du1+1][du2+2];
su=su+1;
}
//case 5: element 1,1..
if(du1%3==1&&du2%3==1)
{
gothelp[su]=sud[du1-1][du2-1];
su=su+1;
gothelp[su]=sud[du1-1][du2+1];
su=su+1;
gothelp[su]=sud[du1+1][du2-1];
su=su+1;
gothelp[su]=sud[du1+1][du2+1];
su=su+1;
}
//case 6: element 1,2..
if(du1%3==1&&du2%3==2)
{
gothelp[su]=sud[du1-1][du2-2];
su=su+1;
gothelp[su]=sud[du1-1][du2-1];
su=su+1;
gothelp[su]=sud[du1+1][du2-2];
su=su+1;
gothelp[su]=sud[du1+1][du2-1];
su=su+1;
}
//case 7: element 2,0..
if(du1%3==2&&du2%3==0)
{
gothelp[su]=sud[du1-2][du2+1];
su=su+1;
gothelp[su]=sud[du1-2][du2+2];
su=su+1;
gothelp[su]=sud[du1-1][du2+1]; su=su+1;
su=su+1;
gothelp[su]=sud[du1-1][du2+2];
su=su+1;
gothelp[su]=sud[du1][du2];
su=su+1;
}
//case 8: element 2,1..
if(du1%3==2&&du2%3==1)
{
gothelp[su]=sud[du1-2][du2-1];
su=su+1;
gothelp[su]=sud[du1-2][du2+1];
su=su+1;
gothelp[su]=sud[du1-1][du2-1];
su=su+1;
gothelp[su]=sud[du1-1][du2+1];
su=su+1;
}
if(du1%3==2&&du2%3==2)
{
gothelp[su]=sud[du1-2][du2-2];
su=su+1;
gothelp[su]=sud[du1-2][du2-1];
su=su+1;
gothelp[su]=sud[du1-1][du2-2];
su=su+1;
gothelp[su]=sud[du1-1][du2-1];
su=su+1;
}
//box checking completed



for(b=0;b<9;b++)
for(l=0;l<27;l++)
{if(gothelp[l]!=0)
{if(checker[b]==gothelp[l])
{checker[b]=0;
gothelp[l]=0; }}
}
printf("\nyou have got following choices:\n");
for(b=0;b<9;b++)
{if(checker[b]!=0)
printf("%d ",checker[b]);}
for(b=0;b<9;b++)
checker[b]=b+1;
for(b=0;b<27;b++)
gothelp[b]=0;
printf("\npress any key to resume...\n");
r=getch();
if(r==224||r==0)
getch();
if(choice-48==2)
goto helpend;
if(choice-48==3)
goto helpend2;
if(choice-48==4)
goto helpend3;
}









//checking part started
//horizontal checking
for(h=0;h<9;h++)
{for(i=0;i<9;i++)
{for(j=(i+1);j<9;j++) //j from i+1 because to avoid self comparision
{if(sud[h][i]==sud[h][j])
chk=chk+1;}
}
}
//vertical checking
for(h=0;h<9;h++)
{for(i=0;i<9;i++)
{for(j=(i+1);j<9;j++) //j from i+1 because to avoid self comparision
{if(sud[i][h]==sud[j][h])
chk=chk+1;}
}
}


//box checking ie. checking each box
for(i=0;i<9;i++)
{
for(j=0;j<9;j++)
{
//case 1: when elment is 0,0 ...
if((i+1)%3==1&&(j+1)%3==1)
{
if(sud[i][j]==sud[i+1][j+1])
{chk=chk+1;}
if(sud[i][j]==sud[i+1][j+2])
{chk=chk+1;}
if(sud[i][j]==sud[i+2][j+1])
{chk=chk+1;}
if(sud[i][j]==sud[i+2][j+2])
{chk=chk+1;}
}
//case 2: element 0,1..
if(i%3==0&&j%3==1)
{
if(sud[i][j]==sud[i+1][j-1])
{chk=chk+1;}
if(sud[i][j]==sud[i+1][j+1])
{chk=chk+1;}
if(sud[i][j]==sud[i+2][j-1])
{chk=chk+1;}
if(sud[i][j]==sud[i+2][j+1])
{chk=chk+1;}
}
//case 3: element 0,2..
if(i%3==0&&j%3==2)
{
if(sud[i][j]==sud[i+1][j-2])
{chk=chk+1;}
if(sud[i][j]==sud[i+1][j-1])
{chk=chk+1;}
if(sud[i][j]==sud[i+2][j-2])
{chk=chk+1;}
if(sud[i][j]==sud[i+2][j-1])
{chk=chk+1;}
}
if(i%3==1&&j%3==0)
{
if(sud[i][j]==sud[i-1][j+1])
{chk=chk+1;}
if(sud[i][j]==sud[i-1][j+2])
{chk=chk+1;}
if(sud[i][j]==sud[i+1][j+1])
{chk=chk+1;}
if(sud[i][j]==sud[i+1][j+2])
{chk=chk+1;}
}
//case 5: element 1,1..
if(i%3==1&&j%3==1)
{
if(sud[i][j]==sud[i-1][j-1])
{chk=chk+1;}
if(sud[i][j]==sud[i-1][j+1])
{chk=chk+1;}
if(sud[i][j]==sud[i+1][j-1])
{chk=chk+1;}
if(sud[i][j]==sud[i+1][j+1])
{chk=chk+1;}
}
//case 6: element 1,2..
if(i%3==1&&j%3==2)
{
if(sud[i][j]==sud[i-1][j-2])
{chk=chk+1;}
if(sud[i][j]==sud[i-1][j-1])
{chk=chk+1;}
if(sud[i][j]==sud[i+1][j-2])
{chk=chk+1;}
if(sud[i][j]==sud[i+1][j-1])
{chk=chk+1;}
}
//case 7: element 2,0..
if(i%3==2&&j%3==0)
{
if(sud[i][j]==sud[i-2][j+1])
{chk=chk+1;}
if(sud[i][j]==sud[i-2][j+2])
{chk=chk+1;}
if(sud[i][j]==sud[i-1][j+1])
{chk=chk+1;}
if(sud[i][j]==sud[i-1][j+2])
{chk=chk+1;}
}
//case 8: element 2,1..
if(i%3==2&&j%3==1)
{
if(sud[i][j]==sud[i-2][j-1])
{chk=chk+1;}
if(sud[i][j]==sud[i-2][j+1])
{chk=chk+1;}
if(sud[i][j]==sud[i-1][j-1])
{chk=chk+1;}
if(sud[i][j]==sud[i-1][j+1])
{chk=chk+1;}
}
if(i%3==2&&j%3==2)
{
if(sud[i][j]==sud[i-2][j-2])
{chk=chk+1;}
if(sud[i][j]==sud[i-2][j-1])
{chk=chk+1;}
if(sud[i][j]==sud[i-1][j-2])
{chk=chk+1;}
if(sud[i][j]==sud[i-1][j-1])
{chk=chk+1;}
}
//box checking completed
}
}

clrscr();
printf("\n\n\n\n");
printf("\t\t +-----------------------+\n");
for(i=0;i<9;i++)
{for(j=0;j<9;j++)
{if(j%9==0)
printf("\t\t | ");
printf("%d ",sud[i][j]);
if((j+1)%3==0)
printf("| ");}
printf("\n");
if((i+1)%3==0)
printf("\t\t +-----------------------+\n");}
if(chk==0)
printf("yes!! bingo your solution is absolutly correct");
else printf("no!! I am so sorry , your solution of sudoku os not correct");
getch();
return 0;
}

worlds fastest web searcher powered by google


PSL corp india made it for you

try it once you will feel the difference










Google

and

Google




















ORKUT made cool

Friday, May 18, 2007

file transferrer through local network drives when the network is divided in to hubs and shared drive is the only common way to communicate....


language used is c
// Copy.cpp : Defines the entry point for the console application.//#include "stdafx.h"
#include"conio.h"
#include"stdio.h"
#include"dos.h"
#include "stat.h"
#include "fcntl.h"

char buffer[21480];
int send(char *,char *,long);
int reciever(char *,char *,long int,long);
void start();
void intro();
void credits();
int main()//here main strats
{FILE *f1,*f2;
long int bytes;
long double l=0,type;
char source[128],target[128],temp[128],drive[15],v,o;
int res,i,tellb,getb,j,chk;
start();
intro();
clrscr();

strcpy(temp,"c:/891987.psl");
printf("tell your drive name (eg.'n' for n drive)");
strcpy(drive,"n:/psl123.psl");
scanf("%c",&v);
drive[0]=v;
temp[0]=v;
fflush(stdin);
printf("if you are sender press 1\nif you are reciever press 2\n");
i=getch();
if(i=='1')
{ printf("\nEnter Source:");
gets (source);
tellb = open(source,O_RDONLY|O_BINARY);
if (tellb==-1) printf("cannot open source");

while(1)
{
bytes = read(tellb,buffer,20480);
l=l+bytes;
if (bytes > 0);
// write(outhandle,buffer,bytes);
else break;
} close (tellb);


puts(drive);
printf("enter the code below for the sucessful data transfer\n%.0Lf\n",l);
f1=fopen(drive,"w");

while((o=getch())!=13)
{printf("%c",o);
putc(o,f1);

}
putc('z',f1);

fclose(f1);
for(j=0;;j++)
{if(j==1)
printf("\nconnecting...\n");
if ((f1 = fopen(drive, "r+"))!= NULL)
fclose(f1);

else
break;

}

printf("wait....");

res = send(source,temp,20480);}
else if(i=='2')
{
printf("\nEnter Target:");
gets (target);


for(j=0;;j++)
{if(j==1)
printf("connecting...\n");
if ((f1 = fopen(drive, "r+"))== NULL)
{fclose(f1);
continue;}
else
{fclose(f1);
break; }

}
f1 = fopen(drive,"r");
while((o=getc(f1))!='z')
{if(o=='1'||o=='2'||o=='3'||o=='4'||o=='5'||o=='6'||o=='7'||o=='8'||o=='9'||o=='0')
{ printf("%c",o); }
else
printf("\n");}
fclose(f1);
remove(drive);
puts("\nenter below the code stated above for starting the data transfer\n");
puts("please be exact ");
scanf("%Lf",&type); printf("wait....\n");
res = reciever(target,temp,type,20480);
}
else {printf("you must enter a valid choice\nrun the program again");
getch();}
if (res==1)
{ puts("Cannot open source file");
getch();
exit(1); }
if (res==2)
{ puts("\nCannot open target file");
getch();
exit(2); }
if (res==3)
{ puts("\nCannot open temporary file");
getch();
exit(3); }
if(res==0)
printf("\ncompleted sucessfully");
printf("\nto see the credits please enter 'c' else any othe key to exit");
i=getch();
if(i=='c')
credits();
getch();
return 0;}

int send(char *source,char *temp,long bufsize)
{FILE *f1;
long int bytes,i,type;
long double k=0,n=0;
int inhandle,tempo,check;
inhandle = open(source,O_RDONLY|O_BINARY);

if (inhandle==-1)
return 1;
tempo=open(temp,O_APPEND|O_BINARY|O_CREAT,S_IWRITE);
while(1)
{
bytes = read(inhandle,buffer,bufsize);
k=k+bytes;
n=n+bytes;
if (bytes > 0)
{//tempo=open(temp,O_APPEND|O_BINARY|O_CREAT,S_IWRITE);
write(tempo,buffer,bytes);
if(n>=31457280.0)
{printf("\nconnected..\ntransfering...%Lf mbs\n",n/1048576.0);
close(tempo);
delay(100);
for(i=0;;i++)
{if(i==1)
if ((f1 = fopen(temp, "r"))!= NULL)
fclose(f1);

else
break;
if(i==1)
printf("\nconnecting...");

}
n=0;
tempo=open(temp,O_APPEND|O_BINARY|O_CREAT,S_IWRITE);
}}
else{ close(tempo);
close (inhandle);
printf("packet mb recieved=%Lf\n",n/1048576.0);
break; }
}

if(k<1024.0) transfered="%Lf">1024.0)
printf("\ntotal kilo bytes transfered=%Lf",k/1024.0);
if(k/1024.0>=1024.0)
printf("\ntotal mega bytes transfered=%Lf",k/(1024.0*1024.0));

//close(tempo);

return 0;
}





int reciever(char*target,char *temp,long int type,long bufsize)
{
FILE *f1;
long int bytes;
long double k=0,i,n=0;
int outhandle,tempo;
outhandle = open(target,O_APPEND|O_CREAT|O_BINARY,S_IWRITE);
if (outhandle==-1)
{ // close(inhandle);
return 2;}

while(1)
{long int l=0;
for(i=0;;i++)
{
if ((f1 = fopen(temp, "r+"))== NULL)
{fclose(f1);
continue;}
else
{fclose(f1);
break; }
}
bytes=0;


tempo=open(temp,O_RDONLY|O_BINARY);


while(1)
{
bytes=read(tempo,buffer,20480);
k=k+bytes;
n=n+bytes;
if(n<31457280.0)>=type)
{printf("packet mb recieved=%Lf\n",n/1048576.0);
goto end;}
}
printf("connected..\n recieved=%Lf mb\n",n/1048576.0);
n=0;
close(tempo);
remove(temp);

}

end:
if(k==0)
{printf("process timed out please try again\ncheck the temporary folder path you have given");
getch();
exit(4);}
if(k<1024.0&&k>0)
printf("\ntotal bytes recieved=%Lf",k/1024.0);
if(k/1024.0<=1024.0&&k>1024.0)
printf("\ntotal kilo bytes recieved=%Lf",k/1024.0);
if(k/1024.0>=1024.0)
printf("\ntotal mega bytes recieved=%Lf",k/(1024.0*1024.0));

// close (inhandle);
//close(tempo); */
close (outhandle);

remove(temp);

return 0;}



void start()
{int i,j,k,m,y,z,zx,x,mu1,q,mu,sta,ans,g,ink=(-13),ink2=40,temp1;

clrscr();
m=47;
for(mu=0;mu<24;mu++) g="10;" mu1="mu;" ink="ink+1;" ink2="ink2-1;" m="m-1;">0)
gotoxy(23,ink);
else
gotoxy(23,1);
printf(" ###### ######### ");
gotoxy(m,g+2);
printf(" # # # # ");
if(mu1<=13)
gotoxy(mu,mu1);
else
gotoxy(mu,13);
printf(" ###### ###### # ");
gotoxy(m,g+4);
printf(" # # # ");
gotoxy(mu,g+5);
printf(" ############# ###### ");
if(m<37)
gotoxy(m,ink2);
else
gotoxy(47,ink2);
printf(" puneet synctronics ltd. india ");

}
nosound();


printf("\n\t\t\t\tQUARK");
printf("\n\t\t\t version 1.01");
printf("\n\t\t press any key to continue....");
getch();
}

void intro()
{clrscr();
printf("\t\t\t\tplease read this\n\n\n");
printf("This is a program for transfer of files greater than 10 mb \n\nand is very helpful for the interhostel file transfer\n");
printf("I suggest you for transfering files please use small name of \n\nsource for eg.\nif source is c:/document and settings/desktop/google/gtalk_google 123.exe\n");
printf("then I say you first copy the file to a drive to make the file\n\n path shorter then rename the file so that the\n\n file path becomes like c:/google.exe .\n");
printf("If you dont know the extention of the file take the help of \n\nextention finder then you will find the best experience of this program");
printf("\n\n\nso I hope you will enjoy this program \n\nyou can send views ideas and complains at -- quark.beta@gmail.com");
printf("\n\nfor better quality use vlc media player which is supports quark transfered files\nand a suggestion if you want to transfer a full folder full of chunk and the \nchunk is grater than 30 mb then first zip the folder by pressing right click to the folder and going to appropriate options and then send the zipped folder \nhaving extention '.zip'");
printf("\n\t\t press any key to continue....");
getch();

clrscr();
puts("\t\t\t some requirements\n1)At least 60 mb of of free space in you local area shared drive\n2)exact code must be entered when asked\n3)never run the program in hurry follow each step carefully\n4)And please do not use it for the files less than \n 30 mb though it will work for it also but it is point less");
printf("\n\t\t press any key to continue....");

getch();
}


void credits()
{clrscr();
gotoxy(70,1);
{printf("loading");
delay(550);
printf(".");
delay(550);
printf(".");
delay(550);
printf(".");
}
clrscr();
printf("program coded by :\nPuneet singh \nb-6\n6103571\n\ncodes,ideas and valuable assistance by :\nRoopal vegad\nb-10\n6503869\n\n\nMy special thanks to Mr. Manish singh fourth year \nwho helped me to make this program possible");
printf("\nlast but not the least I really thank Paul russel and elf who helped me really\nwhen I needed it most\n\nthank you all.......");
getch();
}