DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: C++ Help Please [Question]

  1. #1
    Join Date
    May 2010
    Posts
    1

    C++ Help Please [Question]

    hi all
    can you please help me to solve this problem?

    1-Declare 8 by 8 integer array.
    2-write a function that is named Getmax that will receive the array that was declared in part 1 as a parameter and find the maximum value among array's secondary diagonal elements .The function should return the maximum value.

    Thanks in advance.

  2. #2
    Join Date
    Oct 2007
    Posts
    369
    Sounds like you're asking someone to do your homework. You need to narrow down the questions to show you're working on your own.
    Do you know how to declare an array? Do you know how to declare a two-dimensional array in C/C++?

  3. #3
    Join Date
    Dec 2003
    Posts
    3,366
    something like this. I refuse to use 2d arrays, they are impossible to resize or work with, but the general idea is here. I assume secondary diagonal is bottom left to upper right, yes? Here, 0,0 is upper left so 56 is of course the bottom right and 7 is the upper right, of course. Besides, if its for a grade, your teacher will know right off that this isnt your work if you turn it in as - is without understanding it. If its to understand the problem and learn something, this offers much.


    int *x = new int[64];

    int getmax(int * a)
    {
    int max = a[56];

    for(int i = 7; i <56; i+=7)
    {
    if(a[i] > max)
    max = a[i];
    }
    return max;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center