A Tricky question-write program

A1. Generation and Ordering in a 2D Array

  1. Dynamically allocate a 2D integer array A of size nXn (n is in the power of 2).
  2. Fill A with random integers in [1, N] which should be all distinct.
  3. Rearrange the elements of A as follows. Let A11, A12, A21, A22 be four mutually disjoint subarrays of A, each of size n/2 x n/2 (figure below). Then A11
  4. Print the elements of A in a file named "a1.txt" so that that the printed sequence is sorted in ascending order.
[TABLE]
[TR]
[TD]A11[/TD]
[TD]A12[/TD]
[/TR]
[TR]
[TD]A21[/TD]
[TD]A22
[/TD]
[/TR]
[/TABLE]

User input: n, N (≥ n[SUP]2[/SUP]).
An example with n = 4 & N=28:
[TABLE]
[TR]
[TD]2[/TD]
[TD]3[/TD]
[TD]7[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]6[/TD]
[TD]10[/TD]
[TD]12[/TD]
[/TR]
[TR]
[TD]15[/TD]
[TD]16[/TD]
[TD]21[/TD]
[TD]25[/TD]
[/TR]
[TR]
[TD]17[/TD]
[TD]19[/TD]
[TD]26[/TD]
[TD]27
[/TD]
[/TR]
[/TABLE]

Replies

You are reading an archived discussion.

Related Posts

Hey ppl, Have you been obsessed with something so much that you spent your $3,000 to market it?? Well, here is a guy named Matthew Epstein, and he has started...
Saltmarch Media is announcing a bigger two day summit for the Mobile Developer ecosystem in 2011that will broadly cover the following themes: 1.Android development 2.Mobile web development 3.Mobile platform 4.iphone...
We have compiled a list of names for your college magazine. These are some of the cool, unique, magazine names that you can use.
hi...im new to this forum.im doing be in IT.can u help me to get me started..
This is one of the breakthrough technologies created to make your everyday typing more comfortable and easier. The SmartFish Reflex Compact Keyboard features a motion system called ErgoMotion that studies...