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

How do you print the right-left diagonal of a 2d array ??

Faizzz
6
I know how to print left-right diagonal, but confused with right-left.Please help!!
Oct 10 '13 #1
4 2035
weaknessforcats
9,208 Expert Mod 8TB
Elements on the left-right diagonal are 1,1 2,2 3,3 etc..

Write nested loops to print the entire array.

Then place an if statement before the print so that the only elements that print are the ones where the outer and the inner loop indexes are equal.
Oct 10 '13 #2
Faizzz
6
Can you show me the program please!!
I'm confused with the logic,tried 100's of times.
Oct 10 '13 #3
Faizzz
6
This only works for left to right diagonal.
Oct 10 '13 #4
weaknessforcats
9,208 Expert Mod 8TB
Yes, I know that. The problem is the OP says the right-left diagonal is desired in the thread title but the first post asks for the left-right diagonal.
Oct 10 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: mordac | last post by:
Hello, I was wondering if I could get some opinions on how best to handle printing in a max heap data structure. Right now my heap struct looks as thus: typedef struct heapStruct { int*...
11
by: TG | last post by:
Hi there. I'm trying to create a simple class called Vector which inherit from array. class Vector(array): def __init__(self,length): """initialize a vector of random floats of size length....
3
by: Chris | last post by:
I am clearly missing something simple here.... I have a function (fileTree) that recursively reads all the files in a directory passed to it, and returns an array of the files, I have included...
8
by: Grant Edwards | last post by:
How do you print a numpy array? I tried the obvious print a, print `a`, and print str(a), but none of them work on anything other than trivially small arrays. Most of my real data is elided and...
5
by: Stephen3776 | last post by:
I am doing an inventory control progam and trying to output a multiple array, I am getting an illegal conversion error java.lang.double !d. Can somebody tell me what I am doing wrong or if there is...
11
by: balaraja | last post by:
Hi how to print the diagonal elements of a two dimensional array using for loop Can any one help me...Plzzzzzzzz.. Thanks in advance Bala...
11
by: whodgson | last post by:
I`m trying to write a shuffle function to shuffle a sorted array with an even number of elements but it won`t print past the first 2 elements as shown below. When i print the temp array it only...
7
by: anklos | last post by:
Hi~! I met a problem on printing out a kind of hash array. i.e @array=(1,2,3,4,5,6); $array{$term}=1; diffent $i may contain diifernt $term(more than one term for each $i)
3
by: rotaryfreak | last post by:
Hi, in my database table, i have inserted the following data after creating the appropriate tables: insert into Transaction values(0001, null, 'BransenEnt', 1, 'Mastercard', 99.99,...
5
by: Sean Kernaghan | last post by:
Suppose I have an char array m, and I want to add an int value z into it, how do I convert z into a char so that I can put it into the array? Also, how could I print out the array in reverse? This is...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.