123 Eng

### Engineering the engineers™

Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

Computer Science / IT
Electronics
Electrical
Mechanical
Chemical
Civil

CAT / MBA

GMAT / Foreign MBA
Latest Jobs

Displaying  Source Code(s)

 Graphic simulation of the n_Queen problem using Backtracking. -------------------------------------------------------------------------------- Description : This C code will solve the n-Queen problem using the backtracking approach.The object of this problem is to place n Queens in an nXn chess-board, such that none of them can threaten each othe in one move.It graphically shows the movement of queens, as the algorithm runs.It halts momentarily whenever a solution is found, for the user to view it. It resumes to find other solutions on hitting a key at this juncture.When the queen of the 1st row reaches the last column, and since there is no row behind it to backtrack to, the program exits.The user can exit the program by hitting any key,during the normal running of the program. Parameters :None.The user will be asked to enter the size of the chess-board(eg. Enter 8 if you want to solve for an 8X8 chess-board). #include #include #include #include #include int diag45[12],sol[12],n,chess[12][12],r1,c1,num=0,i,x1,x2,y2,y1; int num1,num2,m=0,x3; void main() { int gd=DETECT,gm,x,y; void queens(int,int); clrscr(); printf("Enter the size of the chess board (12 is the limit) "); scanf("%d",&n); initgraph(&gd,&gm,"c:\tc\bgi"); x=getmaxx(); y=getmaxy(); setcolor(WHITE); x1=y1=0; x2=x/n; y2=y/n; if(x2>=10) { if(x2>y2) x2=y2; else y2=x2; for(i=0;i<=n;i++) { delay(250); line(x1,y1,x1,y); if(i==1) num1=x1/2; x1=x1+x2; //y1=y1+y2; //x2=x2+x/n; //y2=y2+y/n; } x1=x1-x2; x3=x1; for(i=0;i<=n;i++) { delay(250); line(x1,y1,0,y1); //x1=x1+x2; if(i==1) num2=y1/2; y1=y1+y2; //x2=x2+x/n; //y2=y2+y/n; } x1=(x/n)/2; y1=(y/n)/2; } /* if(x2>10)*/ else { x2=y2=10; for(i=0;i<=n;i++) { delay(250); line(x1,y1,x2,y2); x1=x1+10; } for(i=0;i<=n;i++) { delay(250); line(x1,y1,0,y1); y1=y1+10; } x1=5; y1=5; } delay(250); for(i=0;i(n-1)||c>(n-1)) printf("Nonsensical condition reached "); if(m==1) { setcolor(BLACK); setfillstyle(1,BLACK); fillellipse(x1+((c-1)*x2),y1+(r*y2),7,7); } m=0; setcolor(WHITE); setfillstyle(1,WHITE); fillellipse(x1+((c)*x2),y1+(r*y2),6,6); delay(350); //printf("r is %d ; c is %d ",r,c); //getch(); /*delay(100); printf("r is %d ; c is %d ",r,c);*/ d45=r-c; for(i=0;i); num++; getch(); if(c==(n-1)) { //sol[r-1]=sol[r-1]+1; setcolor(BLACK); setfillstyle(1,BLACK); fillellipse(x1+((n-1)*x2),y1+((n-1)*y2),7,7); m=1; //queens(r-1,sol[r-1]); } else { m=1; queens(r,c+1); }} //*********// else { /*for(i=0;i 09/28/2004 06:00 PM Please respond to To cc Subject *** SourceCode: New Code Added *** (Add this code in the Language with following Id) Language Id:1 ScriptName: program to implement who command Content Type:1 Type :37 New Category: Author :raja mukesh Author Email:rajamukesh@gmail.com Description:program to implementing who command using system calls Parameters : Code : #include #include #include int main(void) { struct utmp *n; char *a; int i; setutent(); n=getutent(); while(n!=NULL) { if(n->ut_type==7) { printf("%-9s",n->ut_user); printf("%-12s",n->ut_line); a=ctime(&n->ut_time); printf(" "); for(i=4;i<16;i++) printf("%c",a[i]); printf(" ("); printf("%s",n->ut_host); printf(")
); } n=getutent(); } } ForwardSourceID:NT0000741E ----- Forwarded by Amit M/BLR/TCS on 09/30/2004 09:52 AM ----- 09/29/2004 05:41 AM Please respond to To cc Subject *** SourceCode: New Code Added *** (Add this code in the Language with following Id) Language Id:2 ScriptName: Inventory Management System Content Type:1 Type :3 New Category: Author :Vivek Patel Author Email:vivek_patel9@rediffmail.com Description:This software is designed to manage your inventory system, with a facility of adding, modifying, deleting, viewing, searching, and analyzing a item stored in an inventory. This all functionality is very well comprised using Graphics Outlet for user to go on with it!!! Parameters : Code : /**************************************************************/ /****************INVENTORY MANAGEMENT SYSTEM*******************/ /**************************************************************/ /**************************************************************/ /*Programmed by : Vivek Patel**********************************/ /*For Bugs Free feel to contact********************************/ /*Website : www.vivekpatel.cjb.net*****************************/ /*Email : vivek_patel9@rediffmail.com**************************/ /**************************************************************/ #include #include #include #include #include #include #include #include #include fstream inoutfile; //Menu Global Item #define pixTOrc(x) (8*(x-1)) //convert pixel into row and col format #define INC 5 //Increment Distance Between Menu Items #define ROW 15 //Row Value for Menu Item #define COL 8 //Column Value for Menu Item // To display the Inventory Main menu options typedef char option[15]; option mainMenu[]= { "New Record", "Display", "Search", "Updation", "Deletion", "Analysis", "Exit" }; /*-------------------Inventory Class--------------------*/ class Inventory{ char itemNo[2],itemName[20]; int qty; double price,amt; public: char *getno(){return itemNo;} char *getitem(){ return itemName;} double getamt(){return amt;} void getdata(); void showdata(int,int); void showspecific(); void alterspecific(char *,char *); }; void Inventory :: getdata(){ gotoxy(30,12); cout<<"Enter Item Number : ? "; cin>>itemNo; gotoxy(30,14); cout<<"Enter Item Name : ? "; cin>>itemName; gotoxy(30,16); cout<<"Enter Quantity : ? "; cin>>qty; gotoxy(30,18); cout<<"Enter Price : ? "; cin>>price; amt = price * qty; } void Inventory :: showdata(int x,int y){ gotoxy(x,y); cout.setf(ios::left,ios::adjustfield); cout<>qty; gotoxy(30,18); cout<<"Enter Price : ? "; cin>>price; amt = price * qty; } /*---------------Inventory Codes End------------------*/ /*--------------Menu and all other functions Code--------------*/ //Displays Graphic text in delaying fashion void displayMe(int x,int y,const char *ch,int delayTime){ char d[2]; int len=strlen(ch); for(int i=0;i<=len;i++) { d[0]=ch[i]; d[1]='

Contribute content or training reports / feedback / Comments
job placement papers