Thread: Im new here and asking for help.

  1. #1
    Registered User
    Join Date
    Aug 2005

    Im new here and asking for help.

    Hi all
    Its my first time here.

    I need to write a C program that uses a board of size height x width, and a set of rectangles ri=(heighti x widthi), and I want to find a solution how to cover the whole board with all or with a part of the pieces of the puzzle., in each level, , in each level, I need to check first the horizontal option then the vertical option.

    I already wrote part of the functions but still Im missing the recursive functions I need two recursive calls, one to check the horizontal option and one to the vertical option.

    the output should look like that:

    piece #: 0 1 2 3 4 5
    piece heights: 4 2 2 1 2 1
    piece widths: 6 6 5 6 3 4


    each piece is represnted by a different number.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Fascinating, I'm sure, but I don't see any of your code or your attempt. On that note:

    Quote Originally Posted by kermi3
    Welcome to the boards. If you haven't already done so then please take some time to familiarise yourself with the faq:

    Make sure you have a look at the the posting guidelines:
    Following the rules will ensure you get a prompt answer to your question.

    Remember, too, that the board has a search facility, a link is at the top of your screen:
    It will often get you a quicker answer to your questions than waiting for a response to one you have posted.

    It appears that you are posting a homework assignment or other project.

    Please don't ask people to do all your work for you, See the announcement on Homework at the top of all forums to see what is acceptable or PM me. Basically people are happy to help, but they're not going to do it all for you.

    Show us what you've got, show your code (using code tags), or where you're confused and someone will be happy to help you I'm sure. If it's something that you absolutely don't understand how it works, like you have no clue how qsort works, then ask a general question about the function and I'm sure someone will explain it. Though they may not give you all of the code for it, but someone will explain the concept.

    On obivous homework questions especially, I like to remind people of the board's ninth guildeline, while this board is very helpful to people, make sure you have your instructor's permission before seeking help on assignments. While people on these boards are more than happy to help, we discourage people from asking for help on graded work without the instructor's permission, and we claim no repsonsibilty for any cheating or honor violations.

    Feel free to PM me with any questions.

    Good Luck,


    Read and follow the above instructions, and try your post (in the same thread) again.

    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Aug 2005

    I have got something but its still a mess so...

    #include <stdio.h>
    #define max_Size 19
    #define max_pieces 10
    void arrange(int width[], int height[], int size);
    int check_full(int table[], int size);
    void intial_table(int table[], int size);
    int find_empty_cell(int table[], int size, int pos);
    void structure_of_puzzle(int width_of_puzzle, int height_of_puzzle, int size);
    void pieces(int height_of_puzzle,int width_of_puzzle,int width_of_piece,
    			int height_of_piece,int position);
    void main() {
    	int width[max_pieces], // the array of the pieces' heights
    		height[max_pieces], // the array of the pieces' widths
    		i, // index
    		numH,numW,numP;//heights widths and number of pieces
    	printf("Enter puzzle height( < 20 ) width( < 20 ) number of pieces( <= 10 )\n");
    	printf("Enter array of size %d of piece heights:\n",numP);
    	for (i=0; i<numP; i++)
    	printf("Enter array of size %d of piece widths:\n",numP);
    	for (i=0; i<numP; i++)
    	arrange(width, height,numP);
        for (i=0; i<numP; i++) printf("%3d", i);
    	for (i=0; i<numP; i++) printf("%3d", height[i]);
    	for (i=0; i<numP; i++) printf("%3d", width[i]);
    void arrange(int width[], int height[], int size) { // arranges the arrays in descending fashion
    	int i, j, tmp1, tmp2;
    	for (i=0; i<size; i++) {
    		if (width[i]>height[i]) {
    		}//if width
    		else {
    		for (j=i; (tmp1*tmp2)>=(width[j-1]*height[j-1]) && j>0; j--) {
    		}//for j
    	}//for i
    void intial_table(int table[], int size) {//gives initial value to all the array
    	int i;
    	for (i=0; i<size; i++) table[i]=-10;
    int check_full(int table[], int size) {//checks wether the array is full
    	int i; //index
    	for (i=0; i<size; i++)
    		if (table[i]==-10) return 0;
    	return 1;
    int find_empty_cell(int table[], int size, int pos) {//finds and marks free cells
    	int i;
    	for (i=0; i<size && table[i]!=-10; i++);
    	return i;
    void structure_of_puzzle(int height_of_puzzle, int width_of_puzzle, int size){//gives the dimantions of the puzzle
    	int row,col,index;
    void pieces(int height_of_puzzle,int width_of_puzzle,int width_of_piece[],
    			int height_of_piece[],int position){
    	int i,j;
    	for (i=0;i<=width_of_puzzle;i++)

Popular pages Recent additions subscribe to a feed