473,385 Members | 1,848 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,385 software developers and data experts.

Static Table...

I have to write code in C++ wchich fill Table in this style:
| 2 | 4 | 8 | 16 | 32 | 64 | 128 |
| 192 | 96 | 48 | 24 | 12 | 6 | 3 |
| 4 | 8 | 16 | 32 | 64 | 128 | 256 |
| 320 | 160 | 80 | 40 | 20 | 10 | 5 |
Table [4][7] - Hww to make it?
Feb 2 '06 #1
10 3660
Hi haste.
I have to write code in C++ wchich fill Table in this style:
| 2 | 4 | 8 | 16 | 32 | 64 | 128 |
| 192 | 96 | 48 | 24 | 12 | 6 | 3 |
| 4 | 8 | 16 | 32 | 64 | 128 | 256 |
| 320 | 160 | 80 | 40 | 20 | 10 | 5 |
Table [4][7] - Hww to make it?


int table[4][7] =
{
{ 2, 4, 8, 16, 32, 64, 128 },
{ 192, 96, 48, 24, 12, 6, 3 },
{ 4, 8, 16, 32, 128, 256 },
{ 320, 160, 80, 40, 20, 10, 5 }
};

Didn't test for syntax errors >:-) but should work...

Hope it helps.

Best regards,
Jurko Gospodnetiæ
Feb 2 '06 #2
> int table[4][7] =
{
{ 2, 4, 8, 16, 32, 64, 128 },
{ 192, 96, 48, 24, 12, 6, 3 },
{ 4, 8, 16, 32, 128, 256 },
{ 320, 160, 80, 40, 20, 10, 5 }
};

Didn't test for syntax errors >:-) but should work...


But It must be automatical NO manual.... Loop or something....
Feb 2 '06 #3
haste wrote:
I have to write code in C++ wchich fill Table in this style:
| 2 | 4 | 8 | 16 | 32 | 64 | 128 |
| 192 | 96 | 48 | 24 | 12 | 6 | 3 |
| 4 | 8 | 16 | 32 | 64 | 128 | 256 |
| 320 | 160 | 80 | 40 | 20 | 10 | 5 |
Table [4][7] - Hww to make it?

What have you tried?

--
Ian Collins.
Feb 2 '06 #4
What have you tried?

I'm in work...I can't try...This is for my friend...
Feb 2 '06 #5
haste wrote:
I have to write code in C++ wchich fill Table in this style:
| 2 | 4 | 8 | 16 | 32 | 64 | 128 |
| 192 | 96 | 48 | 24 | 12 | 6 | 3 |
| 4 | 8 | 16 | 32 | 64 | 128 | 256 |
| 320 | 160 | 80 | 40 | 20 | 10 | 5 |
Table [4][7] - Hww to make it?

here you are :)

#define rows 4
#define cols 7
std::vector< std::vector<int> > t2;
for( size_t i = 1; i <= rows; i++ ){
std::vector<int> col;
int iVal = i+1;
col.push_back( iVal );
for( size_t n = 1; n < cols; n++ ){
iVal *= 2;
if( i&1 )
col.push_back( iVal );
else
col.insert( col.begin(), iVal );
}
t2.push_back(col);
}
//print table
for( std::vector< std::vector<int> >::iterator it= t2.begin();
it != t2.end(); ++it ){
std::copy( it->begin(), it->end(),
std::ostream_iterator<int>(std::cout, " | ") );
std::cout << std::endl;
}

--
Marcin Gabryszewski
G DATA Software
www.gdata.pl

address:[FirstName][SurnameFirstLetter]@gdata.pl
Feb 2 '06 #6
haste wrote:
int table[4][7] =
{
{ 2, 4, 8, 16, 32, 64, 128 },
{ 192, 96, 48, 24, 12, 6, 3 },
{ 4, 8, 16, 32, 128, 256 },
{ 320, 160, 80, 40, 20, 10, 5 }
};

Didn't test for syntax errors >:-) but should work...


But It must be automatical NO manual.... Loop or something....


Yes a loop and an algorithm.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Feb 2 '06 #7
haste wrote:
int table[4][7] =
{
{ 2, 4, 8, 16, 32, 64, 128 },
{ 192, 96, 48, 24, 12, 6, 3 },
{ 4, 8, 16, 32, 128, 256 },
{ 320, 160, 80, 40, 20, 10, 5 }
};

Didn't test for syntax errors >:-) but should work...


But It must be automatical NO manual.... Loop or something....


What is allowed then:-?

Stephan

Feb 2 '06 #8
"haste" writes:
int table[4][7] =
{
{ 2, 4, 8, 16, 32, 64, 128 },
{ 192, 96, 48, 24, 12, 6, 3 },
{ 4, 8, 16, 32, 128, 256 },
{ 320, 160, 80, 40, 20, 10, 5 }
};

Didn't test for syntax errors >:-) but should work...


But It must be automatical NO manual.... Loop or something....


Look for patterns. Since there is more than one line there may be more than
one pattern. You have to do the math first, *then* the program. Does the
phrase "arithmetic progression" ring a bell?
Feb 2 '06 #9
haste wrote:
int table[4][7] =
{
{ 2, 4, 8, 16, 32, 64, 128 },
{ 192, 96, 48, 24, 12, 6, 3 },
{ 4, 8, 16, 32, 128, 256 },
{ 320, 160, 80, 40, 20, 10, 5 }
};

Didn't test for syntax errors >:-) but should work...


But It must be automatical NO manual.... Loop or something....


Post your instructors email, and we'll send him the answer.
Feb 2 '06 #10

"haste" <ha***@nospam.irc.pl> wrote in message
news:dr**********@inews.gazeta.pl...
I have to write code in C++ wchich fill Table in this style:
| 2 | 4 | 8 | 16 | 32 | 64 | 128 |
| 192 | 96 | 48 | 24 | 12 | 6 | 3 |
| 4 | 8 | 16 | 32 | 64 | 128 | 256 |
| 320 | 160 | 80 | 40 | 20 | 10 | 5 |
Table [4][7] - Hww to make it?


Hint. 2, 4, 8, 16...
2*2 = 4. 2*2*2 = 8, 2*2*2*2 = 16...
Feb 3 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Thomas Matthews | last post by:
Hi, I have three classes: Category Author Publisher Each of these classes stores its information into a database table of <ID, text>. (They are fields that have a foreign key.) There is...
2
by: 23s | last post by:
Given the following table structure, <table width=100%> <tr> <td>static</td> <td>static</td> <td>variable</td> <td>static</td> </tr> </table>
3
by: Bruce | last post by:
Hello, I have a number of instances in which I need to grab a single value from a table based on an index. Usually that table is an attached table. I know Access provides the DLookup function...
6
by: Pawel Janik | last post by:
Hello.. I have some static functions, that do somple conversion. But to do this conversion, I have to use some conversion tables. And now the question: how to fill this conversion tables (the...
5
by: Mountain Bikn' Guy | last post by:
How would I do this? public sealed class UtilityClass { public static MyObject Object1;//see note below about importance of static object names in this class public static MyObject Object2;...
5
by: Ren? Paw Christensen | last post by:
Hi. Considering the following code, I want this call: Something.Method(); To return "Something". public class BaseClass { public static string Method() {
5
by: rettigcd | last post by:
I have several classes that all have the same static member: class A{ public static string Table = "TableA"; } class B{ public static string Table = "TableB"; }
3
by: Russell Mangel | last post by:
Hi, I would like to encapsulate the following CRC32 routine inside a C++ un-mananged class. I am having difficulty initializing the "const static unsigned int table" inside an un-managed C++...
3
by: schwartzenberg | last post by:
Dear friends, I have just run into a strange DB2 problem. Something i'd some of you would answer, if only shortly. My basic question is: How do i ensure 'insensitive' (ie static) cursors...
15
by: archana | last post by:
Hi all, can anyone tell me differene between public static and private static method. how they are allocated and access?. thanks in advance.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.