Results 1 to 2 of 2
  1. #1
    akulkarni1234 is offline Member
    Join Date
    Jul 2009
    Posts
    1
    Rep Power
    0

    Default manipulation in double dimensional array

    i wish to get output like this
    1 3 2 4 5
    4 5 6 9
    9 11 15
    20 26 where 1 3 2 4 5 is input from user
    my code is

    import java.io.*;
    class nik1234
    {
    public static void main(String args[])throws IOException
    {
    int i,j;
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int arr[][]=new int [20][20];
    for( j=5;j>0;j--)
    {
    i=0;
    arr[i][j]=Integer.parseInt(br.readLine());
    }
    for(j=5;j>0;j--)
    {
    i=0;
    System.out.print("\t"+arr[i][j]);
    }
    for(j=5;j>0;j--)
    {
    i=0;
    while(i<5)
    {
    int c=arr[i][j]+arr[i][j-1];
    System.out.print(c);
    i++;
    }
    System.out.println();
    }
    }
    }

  2. #2
    Harpreet1111 is offline Member
    Join Date
    Jul 2009
    Posts
    12
    Rep Power
    0

    Default

    enter the input in this manner

    1
    3
    2
    4
    5

    because readLine() method considers newline as a delimiter not a whitespace character.

Similar Threads

  1. assign a value to two dimensional array
    By makpandian in forum New To Java
    Replies: 4
    Last Post: 10-05-2011, 06:21 AM
  2. Multi-dimensional array
    By VinTiger in forum New To Java
    Replies: 22
    Last Post: 03-01-2009, 07:51 AM
  3. two-dimensional array
    By kHim in forum New To Java
    Replies: 4
    Last Post: 11-16-2008, 08:21 PM
  4. Array manipulation
    By Ms.Ranjan in forum New To Java
    Replies: 9
    Last Post: 07-18-2008, 10:10 PM
  5. Help with array multi-dimensional
    By barney in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 09:00 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •