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...
4 2760
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.
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
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?
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Amir Michail |
last post by:
Hi,
I was wondering if there is a tool that will perform some heuristic
checking of actual and formal parameters to warn about likely errors.
Such a tool could check that formal and actual...
|
by: bearophileHUGS |
last post by:
I have a class Surface with many methods. Working in the interactive
window I receive an error like this when I write the wrong method name:
>>> table.addGlas()
Traceback (most recent call...
|
by: Vijoy Varghese |
last post by:
Hi Friends,
I am kinda stuck with a SQL query, can some one please guide me?
I have two 'similar' tables
a) open_works_table
b) closed_works_table
now, closed_works_table have 2 extra fields...
|
by: Rimuen |
last post by:
Have a string contains numbers from database. But there is similar numbers
want to remove
Example:
1,3,6,6,6,12,13,14,15,15,15,15
Want to remove the similar numbers so it would be like:...
|
by: Antitax |
last post by:
I have a database with more than 800 adress records
Some of the are similar because some letters in the street adress for
example are not identical, altough they point to the same adress.
Does...
|
by: Steve Jebson |
last post by:
I have 2 Customer Tables from different sources that i would like to
merge into one master table. They have similar data but different
field names and field orders. Is it possible to extract the...
|
by: Megan |
last post by:
Hi everybody-
I'm helping a friend with a music database. She has an old one and is
creating a new one. She wants to compare records and fields in the old
database with records and fields in the...
|
by: Mell via AccessMonster.com |
last post by:
Do you know if there are similar programs through Microsoft or other
platforms compatible via Windows XP that offer a destop application such as
Ms Access that allow easy to learn developing? Ms...
|
by: Tem |
last post by:
I have a single table that contains information of photos
ie.
ID PhotoName PhotoTags
23 my cat cat animal pet
24 cell phone electronic communication
25 tiger animal zoo...
|
by: Tem |
last post by:
Im writing a forum app. I would like to know
what are some ways to find posts with similar content to a selected post.
(match certain important keywords, but not all words)
what is the easiest...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |