473,396 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Similar to n-queens problem

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,
Expand|Select|Wrap|Line Numbers
  1.  #include<stdio.h>
  2. #include<conio.h>
  3. #include<graphics.h>
  4. #include<dos.h>
  5.  
  6. void rook(int f,int m);
  7. void main()
  8. {
  9.  
  10. int m,f ,k=0,poly[8],i,m=0;
  11.  
  12. clrscr();
  13.  
  14. initgraph(&a,&b,"\\tc\\bgi");
  15. x=getmaxx()/8;
  16. y=getmaxy()/8;
  17. for(F=1,k+=y;m<8;i+=F,m++)
  18. for(M=1,l=0;l<8;M+=F,i++)
  19. {
  20. / IN BLACK CHEKS/
  21. setfillstyle(1,0);
  22. poly[0]=M;
  23. poly[1]=F;
  24. poly[2]=M+x;
  25. poly[3]=F;
  26. poly[4]=M+x;
  27. poly[5]=k+F;
  28. poly[6]=F;
  29. poly[7]=M+i;
  30. fillpoly(4,poly);
  31. }
  32. {
  33. ellipse((j+getmaxx()/16),(k+M)-(getmaxy()/16),0,360,17,17);
  34. fillellipse((j+getmaxx()/16),(k+M)-(getmaxy()/16),17,17); 
  35.  
  36. ellipse((F+getmaxx()/16),(k+i)-(getmaxy()/16),0,60,14,14);
  37. ellipse((F+getmaxx()/16),(k+i)-(getmaxy()/16),90,150,14,14);
  38. ellipse((F+getmaxx()/16),(k+i)-(getmaxy()/16),180,240,14,14);
  39. ellipse((F+getmaxx()/16),(k+i)-(getmaxy()/16),270,330,14,14);
  40. }
  41.  
  42. for(i=1,k+=y;m<8;i+=y,m++)
  43. for(F=1,l=0;l<8;M+=x,l++)
  44. if((l%2==1 && m%2==0) || (l%2==0 && m%2==1))
  45. 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))
  46. {
  47. setfillstyle(1,0);
  48. poly[0]=j;
  49. poly[1]=i;
  50. poly[2]=j+x;
  51. poly[3]=i;
  52. poly[4]=j+x;
  53. poly[5]=k+i;
  54. poly[6]=j;
  55. poly[7]=k+i;
  56. fillpoly(4,poly);
  57. }
  58. return 0;
  59. }
  60.  
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...
Jul 31 '07 #1
4 2760
weaknessforcats
9,208 Expert Mod 8TB
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.
Aug 1 '07 #2
Idea
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
Aug 2 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
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?
Aug 2 '07 #4
r035198x
13,262 8TB
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.
Aug 2 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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...
11
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...
0
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...
6
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:...
2
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...
2
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...
5
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...
12
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...
6
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...
2
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.