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 3300552
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:40:22+00:00 2026-05-17T20:40:22+00:00

I have the following matrix 1 2 3 4 5 6 2 3 4

  • 0

I have the following matrix

 1 2 3 4 5 6
 2 3 4 5 6 1
 3 4 5 6 1 2
 4 5 6 1 2 3
 5 6 1 2 3 4
 6 1 2 3 4 5

…and I want to have it in a table

 | 1 2 3 4 5 6
---------------
1| 1 2 3 4 5 6
2| 2 3 4 5 6 1
3| 3 4 5 6 1 2
4| 4 5 6 1 2 3
5| 5 6 1 2 3 4
6| 6 1 2 3 4 5

Having n elements is it possible to print such a table dynamically?

    public static void main ( String [ ] args ) {
        int n = Integer.parseInt(args[0]);
        for(int w = 1; w <= n; w++){
            System.out.println("");
            for(int p = w; p <= n + w - 1; p++){
                System.out.print((p-1)%n+1 + " ");
            }           
        }
    }
  • 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-05-17T20:40:22+00:00Added an answer on May 17, 2026 at 8:40 pm

    Depends on the array, assuming that you know the array size beforehand sure. In Java arrays can be jigged aka subarrays do not have to be same size, what in mind:

    For test case:

    public static void main(String[] args) {
        System.out.println(toTableString(new int[][] { { 1, 2, 3, 4, 5, 6 },
                { 2, 3, 4, 5, 6, 1 }, { 3, 4, 5, 6, 1, 2 },
                { 4, 5, 6, 1, 2, 3 }, { 5, 6, 1, 2, 3, 4 },
                { 6, 1, 2, 3, 4, 5 } }));
        System.out.println();
        System.out.println(toTableString(new int[][] { { 1 }, { 2, 3 },
                { 3, 4, 5 }, { 4, 5, 6, 1 }, { 5, 6, 1, 2, 3 },
                { 6, 1, 2, 3, 4, 5 } }));
        System.out.println();
        System.out.println(toTableString(new int[][] { { 1 }, { 20, 300 },
                { 3000, 40000, 50000 }}));
    }
    

    Output:

     | 0 1 2 3 4 5 
    ——————————————
    0| 1 2 3 4 5 6 
    1| 2 3 4 5 6 1 
    2| 3 4 5 6 1 2 
    3| 4 5 6 1 2 3 
    4| 5 6 1 2 3 4 
    5| 6 1 2 3 4 5 
    
     | 0 1 2 3 4 5 
    ——————————————
    0| 1 
    1| 2 3 
    2| 3 4 5 
    3| 4 5 6 1 
    4| 5 6 1 2 3 
    5| 6 1 2 3 4 5 
    
         | 00000 00001 00002 
    ————————————————————————
    00000| 00001 
    00001| 00020 00300 
    00002| 03000 40000 50000 
    

    Run online: link

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this following numpy matrix that I want to sort in ascending order
Say I have the following matrix which is vertical : {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} And I want
I want to achieve the following: Have a AxBxC matrix (where A,B,C are integers).
I have a column stochastic matrix A and want to solve the following equation
suppose I have the following matrix a = 2 NaN NaN 4 NaN 3
Say I have the following matrix: A = randi(10, [6 3]) 7 10 3
In R I have the following matrix (each row represents a bootstrap 95% confidence
Say I have the following similarity matrix : matrix = [[100.0, 66.666666666666671, 61.539999999999999, 59.260000000000005,
I have the following matrices: m = matrix(c(1:12), nrow=4) p = matrix(c(2,7,11), nrow=1) Per
I have the following code to convert the type of the matrix using cv::Mat.convertTo()

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.