473,401 Members | 2,127 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,401 software developers and data experts.

Fill a 2-D Box

Given a 2^n by 2^n checkerboard with any one square deleted, it is possible to cover this board with L-shaped pieces.

For example, a 4x4 checkerboard coudl be covered like this.



w w u u
w t t u
j ♣ t e
j j e e


you shall represent the checkerboard ising a dynamically allocated 2-D array. The user shall give you the value of "n" for the 2^nx2^n matrix.

The prototype of the recursive function that you'll write is given below:

void LRec(int row, int col, int** array, int size, int ptx, int pty);

ptx and pty indicate the row and column indices of the space in array that shall remain filled with ♣.


Expand|Select|Wrap|Line Numbers
  1. #include <graphics.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <conio.h>
  5. #include <iostream.h>
  6. #include <string.h>
  7. #include <math.h>
  8. #include <process.h >
  9.  
  10. void LRec(int row, int col, int** array, int size, int ptx, int pty);
  11.  
  12.  
  13. int main(void)
  14. {
  15.  const int TWO=2;
  16.  int n;
  17.  clrscr();
  18.  cout<<"Enter the value of n for a 2^n x 2^n matrix :";
  19. cin>>n;
  20.  if (n<0)
  21.   {
  22.   cout<<"sorry!";
  23.   return 1;
  24.   }
  25.  int power2=(int)pow(TWO,n);
  26.  int power2=pow(TWO,n);
  27.  int** LArray = new int*[power2];
  28.  int i,j;
  29.  for (i=0; i<power2; i++)
  30.   LArray = new int[power2];
  31.  
  32.  for (i=0; i<power2; i++)
  33.   for (j=0; j<power2; j++)
  34.    LArray[j] = 5;
  35.  int ptx, pty;
  36.  srand ( (unsigned)time(NULL));
  37.  ptx = rand()%(power2);
  38.  pty = rand()%(power2);
  39. cout <<"ptx= "<<ptx<<"   pty = "<<pty<<endl;
  40.  
  41.  LRec(0,0, LArray, power2, ptx, pty);
  42.  cout<<endl;
  43.  
  44.  
  45.  for (i=0; i<power2; i++)
  46.   {
  47.   for (j=0; j<power2; j++)
  48.    cout<<(char)LArray[j]<<"  ";
  49.   cout<<endl<<endl;
  50.   }
  51.    getch();
  52.  
  53.    return 0;
  54. }
  55. void LRec(int row, int col, int** array, int size, int ptx, int pty)
  56.  {
  57.  
  58. //Write your code here &
  59.   }
  60.  
Feb 6 '07 #1
4 1964
horace1
1,510 Expert 1GB
which operating system and compiler are you using?
Feb 6 '07 #2
i m using Turbo C 3.0 uner DOS environment
Feb 7 '07 #3
I think there is no body brave enough to solve my problem.Where is the community going??
Feb 11 '07 #4
Ganon11
3,652 Expert 2GB
I think we've interpreted your question as a homework assignment, and without you asking us for help or clarification, we're not sure what you want.
Feb 11 '07 #5

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

Similar topics

6
by: John J. Lee | last post by:
1. Why do I get this in my minibuffer when I do C-c C-c in a python-mode buffer containing the following valid Python code? Wrong type argument: sequencep, cpython ----START #!/usr/bin/env...
3
by: red floyd | last post by:
I got an error by using std::fill to set an array of pointers to 0. e.g.: class XXX; XXX* v; std::fill(v, v+30, 0); // <-- ERROR -- cant' match template type I have to either explicitly...
6
by: JeffB | last post by:
I have tried several different methods of getting a datagrid to fill with information. Below is the code I'm now using. When viewed in the browser and the text box filled with a parameter value...
6
by: M | last post by:
Hi, Does SqlDataAdapter always close the connection (assuming connection was closed before calling Fill()), even if an exception occurs while calling Fill()? Example: try {...
2
by: Stanav | last post by:
Hello all, I'm developing a web application using VB.Net 2003 and Framework 1.1. This application queries an AS/400 database. I'm using the IBM OleDb provider that came with IBM Client Access for...
5
by: moondaddy | last post by:
I have a website where cataloge pages are populated by calling a stored procedure on sql server. I use the sql data adapter's fill method to call this stored procedure and fill the dataset. about...
2
by: pwh777 | last post by:
I need help in understanding the DataAdapter Fill method and how it relates to the binding to controls on a form. I have a table called tbl_CID_XRef on SQL Server. I have written as a test the...
30
by: Raymond Hettinger | last post by:
Proposal -------- I am gathering data to evaluate a request for an alternate version of itertools.izip() with a None fill-in feature like that for the built-in map() function: >>> map(None,...
12
by: Raymond Hettinger | last post by:
I am evaluating a request for an alternate version of itertools.izip() that has a None fill-in feature like the built-in map function: >>> map(None, 'abc', '12345') # demonstrate map's None...
1
by: dellis | last post by:
Problem: My project was initially created without putting passwords in the connection string. When I added the password in the connection string, it disappears when performing a database fill. I...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.