P: 2

hi guys m new out here and need help with an assignment due next week.The assignmnet is some what related to eight queens problem but not fully, you can say the basic is taken from that problem.
Herez the question,
I have 4 male pieces and 4 female pieces, and a 8x8 board (like a chess board). I would like to place one piece per row such that:
there is one piece per column
no two male pieces are in adjacent rows or columns; and similarly with female pieces.
no two male pieces are in the same diagonal, and no two female pieces are in the same diagonal.
it is ok to have a male and female in the same diagonal.
the solution i tried using visual c++ is this,  #include<stdio.h>

#include<conio.h>

#include<graphics.h>

#include<dos.h>


void rook(int f,int m);

void main()

{


int m,f ,k=0,poly[8],i,m=0;


clrscr();


initgraph(&a,&b,"\\tc\\bgi");

x=getmaxx()/8;

y=getmaxy()/8;

for(F=1,k+=y;m<8;i+=F,m++)

for(M=1,l=0;l<8;M+=F,i++)

{

/ IN BLACK CHEKS/

setfillstyle(1,0);

poly[0]=M;

poly[1]=F;

poly[2]=M+x;

poly[3]=F;

poly[4]=M+x;

poly[5]=k+F;

poly[6]=F;

poly[7]=M+i;

fillpoly(4,poly);

}

{

ellipse((j+getmaxx()/16),(k+M)(getmaxy()/16),0,360,17,17);

fillellipse((j+getmaxx()/16),(k+M)(getmaxy()/16),17,17);


ellipse((F+getmaxx()/16),(k+i)(getmaxy()/16),0,60,14,14);

ellipse((F+getmaxx()/16),(k+i)(getmaxy()/16),90,150,14,14);

ellipse((F+getmaxx()/16),(k+i)(getmaxy()/16),180,240,14,14);

ellipse((F+getmaxx()/16),(k+i)(getmaxy()/16),270,330,14,14);

}


for(i=1,k+=y;m<8;i+=y,m++)

for(F=1,l=0;l<8;M+=x,l++)

if((l%2==1 && m%2==0)  (l%2==0 && m%2==1))

if((Row==2,4,6 or 8 && Col==1,3,5 or 7)  (Row==1,3,5 or 7 && Col==2,4,6 or 8))

{

setfillstyle(1,0);

poly[0]=j;

poly[1]=i;

poly[2]=j+x;

poly[3]=i;

poly[4]=j+x;

poly[5]=k+i;

poly[6]=j;

poly[7]=k+i;

fillpoly(4,poly);

}

return 0;

}

i want to know if its right or wrong and i don't know much of C++ programming and i have to convert it into that.Can some one help me n that.
thanks and regards,
Idea...
 
Share this Question
Expert Mod 5K+
P: 9,197

Does it work for you?
That is, it produces the desried results. Yes?
I can only help where you are stuck but I cannot do your debugging.
 
P: 2

hi..
yah it does work in visual basic and outputs da desired result,but am unable 2 figure out,how 2 write in c language as da codes are in visual c,m confused as i dono much of c,i tried bt gt confused thts y asked..if anyone could help me as whch code have to be change 2 wht..
thnkx..n regards
idea
  Expert Mod 5K+
P: 9,197

i dono much of c,i tried bt gt confused thts y
I'm sorry but your are kind of breaking up. Must be a bad connection.
Could you repeat that in English?
  10K+
P: 13,264

hi..
yah it does work in visual basic and outputs da desired result,but am unable 2 figure out,how 2 write in c language as da codes are in visual c,m confused as i dono much of c,i tried bt gt confused thts y asked..if anyone could help me as whch code have to be change 2 wht..
thnkx..n regards
idea
See the guidelines. You will need to be able to communicate to get help.
    Question stats  viewed: 2393
 replies: 4
 date asked: Jul 31 '07
