I will do it :D
Printable View
I will do it :D
Edit your code and when you do, go into the "Advanced" editor, and highlight your code. Then click on the # icon in the advanced editor toolbar (just right of center).
That will make your code look MUCH better. If you then indent it so subordinate lines of code are 2 to 5 char's more indented than the line they are subordinate to, it will help a great deal.
Getting an English translation of the Spanish, would also help. Google translates, (as well as others), for free.
The forum editor, (you need to edit your post, not your program).
This is perhaps the "put 8 queens on a chessboard so that none are attacking any of the others", problem?
OK, what are you looking to do here?
Do you want a function, a stand alone program, or?
no no i would like someone to help me to start my program, i am really afraid of this because i must to have this ready really soon!!! but i don't know who to program this into C because i just know how to program in java or some php
There's no sense in "starting your program", for you. If you can't even start your program, there is no chance at all, that you contribute anything.
So somebody, (or somebodies), would have to do everything.
Maybe you can find someone who will do that for you, but I won't. I expect carpenters to at least know how to cut wood, and even beginning programmers, to know how to start a C program.
This tutorial might help, greatly:
Cprogramming.com: How to Get Started with C++
(includes C, btw).
ok, well i study so hard and i MUST to pass this subject and i don't know WHY nobody want to help mE at all, i don't have time to learn programming in C because i need a qualification into de university, don't know why there are too many selfish people all over the world, thank you indeed!! and is not in C++ is on C
I don't see any selfish people in this forum, just incompetent people who think the world would hand-feed them.
no no it is really selffish if i am requesting for help it is because i am having troubles in doing something, if i can help someone i would do it!!! but everybody don't think the same, i am really afraid i can't have my program ready soon, i am studying so hard and my time is nOOOOT so much, but it is ok!! i will do it by my own!!!!!!!!!!!!1
Well... Adak is neither being selfish nor nasty. He's just given you the best advice possible...
Learn C.
You are obviously in a course that requires you to know C. We would be doing you no favours at all if we did your homework for you... You wouldn't learn a thing and the first time you found yourself having to write code without half the planet to prop you up, you'd fall flat on your face.
You do yourself no favours by trying to do an end run around your own learning experience.
Ok, simple question... if you can't find the time to do your studies and keep up with your courses... what the heck are you wasting your time on?
Really... think about this. You've just dug yourself a real nice hole... perhaps you would be smart to stop digging while you can still climb out...
If you have "studied so hard", then how is it that you can't even write out the first lines of every C program?
You know nothing about C, and have boxed yourself into a tough spot. I get that!
The best advice is STILL to have you learn the basics in a tutorial, and THEN help you with this code problem.
Not everyone who pushes you, is being mean. Some are pushing you off the tracks of the oncoming train.
Stop arguing on here and go work on your program or whatever you have to do. Unless you have some code to show, there is no point of this thread continuing. There is also no point in trying to shame people into doing the work for you.
Go to the tutorial link (it's for C if you click on the "go here" on the first page). See how a C program is started:
include a file(s), int main(void), opening curly brace, code next, and then return 0, and ending curly brace.
and just get it started a bit. There is still time, and we can help you, but knock off the "poor me" stuff and the name calling.
That won't help.
We will help, but YOU have to start the program's code. That's the forum policy.
And when I was a youngser, I used to walk barefoot in snow, 3 miles, to school on the far side of town... and it was uphill in both directions!
ok!! i will DO IT!! and show you that i can:'(
You forgot "waist deep" on that snow, CT! :p :p
alexdavid, you want tough, you check out Haiti after the earthquake and cholera - and having to put up with an upper class that's ripping them off, decade after decade. That's tough.
Just needed to tick her off, and she's good to go. :DQuote:
ok!! i will DO IT!! and show you that i can:
yes i know how many people do people have! i know, and sorry sorry sorry ( i am a woman) this is my boyfriend's user!! thanks a lot for your advices, i am just nervous on everything
Understandable, no problem.
Ok... final comment then I'm done with this...
If you are scared of computers, I'd have to suggest you may be investing in the wrong career...
She's scared because of the demands for the class, and her limited time, and etc.
nonono i am not scared on computers i am really happy with my carreer it is just the time, i think is getting me out, i really LOVE COMPUTEEEERS!!!!
Adak knows :D
I was going to start deciphering your code into C, in anticipation of your follow up posts, but I see you have deleted it.
It has some unusual features that aren't allowed in C, (like negative indeces in the array), and will take some work.
Code:# Define FALSE 0
# Define TRUE 1
int a [1 .. 8] / / a [i] = TRUE indicates that there is a queen in the i-th column
int b [2 .. 16] / / b [i] = TRUE indicates that there is a queen in the i-th
/ / Diagonal from the upper right
/ / To the lower left
int c [-7 .. 7] / / c [i] = TRUE indicates that there is a queen in the i-th
/ / Diagonal from the left end
/ / Top to the bottom right
int x [1 .. 8] / / indicates the position of the queen in the ith column
void try (int i)
begin
int j
for (j = 1 to 8)
if (a [j] and b [i + j] and c [i, j]) then
begin
x [i] = j
a [j] = FALSE
b [i + j] = FALSE
c [i, j] = FALSE
if (i <8) Then try (i +1) else print result
a [j] = TRUE
b [i + j] = TRUE
c [i, j] = TRUE
end
end
main ()
begin
for (i = 1 to 8) a [i] = TRUE
for (i = 2 to 16) b [i] = TRUE
for 9i =- 7 to 7) c [i] = TRUE
try (1)
end
thanks a lot for your help in advanced, actually i am requesting for this help because after this i have to use fork() for making a process and the the child processes too, but that i can do it, because i have been reading on it :D i will show you later!! THANKS A LOT!!!
after that i am going to program by threads with the pthread.h on linux!!!
Any more info on this code?
I'm stuck on trying to understand what it's doing. First, I don't see an array for the board[8][8] (or so), and the 2 to 16 arrays are weird. It says "diagonals", but diagonals on a chessboard are just 8 squares long, so I'm thinking it's really two diagonals (which would be 15 squares)??
Then, in main(), it sets all the array elements to TRUE, but mentions that TRUE indicates the element has a queen??
The "coup de grace" is the array with negative and positive indeces, of course!
My questions:
How much can you change these arrays and logic, and be OK?
This IS the put 8 queens on the chessboard without attacking any of the other queens, RIGHT?
I believe we've all been there, at some time or other.Quote:
sometimes i need someone to tick me off and then i will react
hello, thank you for answering, i can change it as much as i could, the thing is to solve the 8 queen problem using a master/slave programming, which means that the master will start to fill a board with a queen starting by the diagonal, then this board must to be delivered to the slave, and then that slave have to do its own job of filling up the 7 queens into that board, for that they request me to use fork() which creates child processes with the same code but an only ID!! and then the parent have to wait until the slaves finish their job and report it at the end :D
Are you actually under the impression that the pseudocode you posted -- which is directly from your assignment, based on the deleted post at DevShed I found in the Google cache (post 5) is C?
That code is NOT C, and it says that right in the original post that it's from: Dr. Wirth's book on Algorithms and Data Structures.
Understand:
1) C can't use negative indeces in an array.
2) Dr. Wirth is the father of Pascal, and an innovator in Modula 2 (iirc), and other languages.
He was a top notch programmer, author, and researcher in computer languages. I'm not, and I can't wrap my head around the algorithm, fully.
(Doubly difficult since I don't know Pascal, which is what this program is written in apparently).
The 8 queen's problem isn't that tough, and you can do your fork and such to it, as required. But don't use this program, as anything more than a loose template.
Is the 8 queens problem what has you stuck, or is it the child processes, etc.?
I'm thinking it was some kind of hybridized pseudocode....
This is pascal...
Code:program Procedures;
procedure GetName;
var
Name: String;
begin
Writeln('What is your name?');
Readln(Name);
if Name = '' then
Exit;
Writeln('Your name is ',Name);
end;
begin
GetName;
end.
I have read (some of) Wirth's books, he likes to use simplified versions of IBM's PL/1 and (in his later books) Oberon, which he created. Both look similar to Pascal at a glance.
Offtopic: His books on compiler building are actually pretty good. The last version of his book on compiler building can be found on the web as a free download. (If you fancy that sort of thing).
LT
Good info.
Might have to look up Wirth's book although I've never messed with compiler building before. I suspect it will create a large wooshing sound as it zips over my head, but still ... :D
So now you have no trouble believing I know nothing (almost), about Pascal, anyway! :p
Let's keep the discussion here, for the simple reason that buds here on the forum, know a HELL of a lot more about programming than I do. Also**
Have you considered using fork() and then wait() for the parent?
Just looking in Google, I found post after post on various forums (including our own C++ forum, involving fork().
** last time I did that, the boy friend got jealous, and took a knife to my avatar. That's why I don't have an avatar, to this very day <tear> --- RIP avatar! :p :p :p :D
Here's what I suggest:
1) The thread part of this is a small amount of code, and how it should be implemented (as far as an algorithm), is explained in your post:
Place the first queen, and then find the rest (if possible) with the child thread.
I'm no expert on threads and processes, but that doesn't seem like a big big deal, because it's just a few lines of code, and many examples and discussions of it, on the net.
My point being, that you should concentrate on getting the rest of the program coded up and working, first.
Then add the threading part.
2) With #1 in mind, you have to know that this code you posted can't work in C, as it is. It's impossible. If you can code up an 8 queens program yourself, do that. If not, see what you can find, that IS C code, and you have some chance of understanding.
Sometimes you can take a program in another language, and "translate it" into C pretty easily. But not the posted program. It's deeply integrated into the language (PL/1, Oberon, or whatever it is), and can't be "translated".
Also, it's from a book by a world famous author - you certainly can't turn it in and say "here's my program". They might even expel you for such an obvious act of plagiarism.
Your thoughts?