Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8838405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:59:11+00:00 2026-06-14T09:59:11+00:00

I want to add together the cross-diagonal elements in a matrix. For example, I

  • 0

I want to add together the cross-diagonal elements in a matrix. For example, I have a 3*3 Matrix which is two dimensional, I want to convert it to one dimensional:

      -------------------
      |  1  |  2  |  3  |
      -------------------
 A=   |  4  |  5  |  6  |
      -------------------
      |  7  |  8  |  9  |
      -------------------

final output will be,

     ____ ____ ____ ____ ____
 B= |1   | 6  | 15 | 14 |  9 |
    |____|____|____|____|____|

First cross-diagonal A[0][0] will be copied to B[0].

Then the next cross-diagonal elements A[1][0] and A[0][1] will be added and copied to B[1], i.e. 4 and 2 will be added.

Then the next cross-diagonal elements A[2][0] and A[1][1] and A[0][2] will be added and copied to B[2], i.e. 7, 5 and 3 will be added.

And so on…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:59:13+00:00Added an answer on June 14, 2026 at 9:59 am

    Notice that for each diagonal, the sum of row-index and column-index is equal to the index of B array. Based on this fact, you can make a algorithm like this:

    // assuming the width and length of the Matrix is N
    // it's good you have some ideas of the range of idea, try figure it out by yourself? 
    // definitely it should be a function of N
    for (int i=0;i<F(N);i++) { 
      for (int j=0;j<=i;j++) { // consider why j should be in range (0,i) ?
        // some cumulatively add here
      }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add two files together, which one of them has only 1
I have made two thread running together with Netbeans and i want to add
I have the following code. I want to add two input fields together and
I want to add two numbers together but when one of those numbers is
I have two NSArray objects and I want to add the two arrays together
I want to add two maps together with the following behavior. if key exists
I have two fields in a form (ip:port) seperately. I want to add them
Possible Duplicate: Call web service from jQuery I want to add two numbers together,
I have two Datetime fields that I wish to add together. They are in
I want to add a button that when pressed will lock two sliders together

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.