AboutPrince M. Premnath Expertise Years of research in C/C++ Will bring you all facts regarding , OOPS , SVGA , MOUSE , BIOS , IVT , Feel free to query me :-)
Question QUESTION: Sorry for the bad question construction. This code below is a piece of code i got from my C language program. So my question is that i want to change this piece of code into the C++ language.
a) oddnumber(vector<vector<int> > &met, int n);
Thank you........
ANSWER: Hi dear LEO!
vector is actually a part of the standard Template Library , and what you have given me is just a function prototype! Hope nothing to convert with this function into C !
Better try to understand how vector works ( A vector is, essentially, a resizeable array; the vector class allows random access via the [] operator, but adding an element anywhere but to the end of a vector causes some overhead as all of the elements are shuffled around to fit them correctly into memory. Fortunately, the memory requirements are equivalent to those of a normal array.)
Hope ill answer better if you send me the code associated with this function !
Thanks and Regards!
Prince M. Premnath
---------- FOLLOW-UP ----------
QUESTION: oddnumber(vector<vector<int> > &met, int n);
This is the code associated with the function prototype above.
void oddnumber(vector<vector<int> > &met, int n)
{
int jxn = n * n;
int i=0, j = n/2;
for (int k = 1; k <= jxn; ++k)
{
Answer Dear Leo!
Sure this program is a C++ program but its coded in conventional way ( procedural method )more over vector class expect that the source file should be strictly a C++ file.
No needs to carry over any special steps in conversion of this code , just embedded this function inside a class !