Page 1 of 2 12 LastLast
Results 1 to 20 of 21
  1. #1
    Dlovan is offline Member
    Join Date
    Jan 2014
    Posts
    16
    Rep Power
    0

    Default how to do it with array !

    hello all programmers

    i have this matrix by using 2 array dimension

    2 2 2
    3 3 3
    4 4 4


    i want to find sum of bottom Triangle like that

    2
    3 3
    4 4 4


    after that i want to find sum each of column like that

    9 9 9

    and i have another question sorry if my question is more but really i need that i want write a program by using array the output like that

    2 2 2
    3 3
    4 4 4

    please quick reply because i need it


    thanks for all

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,785
    Blog Entries
    7
    Rep Power
    21

    Default Re: how to do it with array !

    Let i be a row index number and let j be a column index number; for, say, the lower triangular matrix, the relation i >= j should hold. This observation is enough to construct two loops that iterate over the lower triangular matrix ... your other questions are a variation on the same theme and I guess you can manage now ...

    And I'm sure you need this, but don't hurry us, because we don't need it and we've probably done this more than often. We are all volunteers here so you can't come here with a 'please quick reply'.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Dlovan is offline Member
    Join Date
    Jan 2014
    Posts
    16
    Rep Power
    0

    Default Re: how to do it with array !

    ok my friend @JosAH but toomorow i have examination in college i want to do it , and about volunteers yeah we are special thanks for all the members here , but can you do it practical ! and put all the code here !!

    or if you give some topic like my question please give me


    regards

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,785
    Blog Entries
    7
    Rep Power
    21

    Default Re: how to do it with array !

    Quote Originally Posted by Dlovan View Post
    ok my friend @JosAH but toomorow i have examination in college i want to do it , and about volunteers yeah we are special thanks for all the members here , but can you do it practical ! and put all the code here !!

    or if you give some topic like my question please give me
    So all you want to do is scrape 'teh internet for teh codez'; that is cheating and I (we) won't give it to you; we will help you though if you show some attempts yourself and got stuck; this forum is not a rent-a-coder forum.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Dlovan is offline Member
    Join Date
    Jan 2014
    Posts
    16
    Rep Power
    0

    Default Re: how to do it with array !

    my friend i try it more than 10 count and this is my code

    Java Code:
    import java.util.*;
    class twodimention
    {
    	int x[][]=new int[3][3];
    
    	void input()
    	{
    
    System.out.println("Please Enter number " );
    Scanner s1=new Scanner (System.in);
    for (int i=0;i<3;i++)
    {
    for (int j=0;j<3;j++)
    {
    	x[i][j]=s1.nextInt();
    }}}
    
    void out()
    {
    	for (int i=0;i<3;i++)
    	{
    	for (int j=0;j<3;j++)
    	{
    		System.out.print(x[i][j]);
    }
    System.out.println();
    }
    System.out.println("----------------");
    }
    void sumrow ()
    {
    	int sum=0;
    	int avg;
    	for (int i=0;i<3;i++)
    		{
    		for (int j=0;j<3;j++)
    		{
    				sum=sum+x[i][j];
    System.out.println("Sum of row = "+sum);
    }}
    System.out.println("----------------");
    }
    void sumcol ()
    {
    	int sum=0;
    	int avg;
    	for (int i=0;i<3;i++)
    		{
    		for (int j=0;j<3;j++)
    		{
    				sum=sum+x[j][i];
    System.out.println("Sum if column = "+sum);
    }}
    System.out.println("----------------");
    }
    void min()
    {
    	int min=x[0][0];
    	for (int i=0;i<3;i++)
    	{
    		for (int j=0;j<3;j++)
    		{
    	if (min>x[i][j])
    	{
    		min=x[i][j];
    }}}
    System.out.println("Minimize number is  : " +min);
    System.out.println("----------------");
    }
    void minrow()
    {
    	int min=x[0][0];
    
    		for (int j=0;j<3;j++)
    		{
    	if (min>x[0][j])
    	{
    		min=x[0][j];
    }}
    System.out.println("Minimize of row : " +min);
    System.out.println("----------------");
    }
    void mincol()
    {
    	int min=x[0][0];
    
    		for (int i=0;i<3;i++)
    		{
    	if (min>x[i][0]){
    		min=x[i][0];
    }}
    System.out.println("Minimiz of column : " +min);
    System.out.println("----------------");
    }
    void max()
    {
    	int min=x[0][0];
    	for (int i=0;i<3;i++)
    	{
    		for (int j=0;j<3;j++)
    		{
    	if (min<x[i][j])
    	{
    		min=x[i][j];
    }}}
    System.out.println("Max number is : " +min);
    System.out.println("----------------");
    }
    void diagonal ()
    {
    int i = 0, j = 0;
    	                int sum1 = 0, sum2 = 0;
    	                for (j = 0; j < x.length; j++) {
    	                        for (i = 0; i < x.length; i++)
    	                                System.out.print(x[j][i] + " ");
    	                        System.out.println();
    	                }
    	                for (j = 0; j < x.length; j++) {
    	                        sum1 = sum1 + x[j][j];
    	                }
    	                i = x.length - 1;
    	                for (j = 0; j < x.length; j++) {
    	                        if (i >= 0) {
    	                                sum2 = sum2 + x[j][i];
    	                                i--;
    	                        }
    	                }
    	                System.out.println("Sum of Digonal :" + sum1 + " and " + sum2);
    	                System.out.println("----------------");
    
    }
    public static void main (String[]args)
    {
    twodimention op = new  twodimention ();
    op.input();
    op.out();
    op.sumrow();
    op.sumcol();
    op.min();
    op.max();
    op.minrow();
    op.mincol();
    op.diagonal();
    }
    }
    if you know all i want to do it , please do it for me

    regards

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,785
    Blog Entries
    7
    Rep Power
    21

    Default Re: how to do it with array !

    Quote Originally Posted by Dlovan View Post
    if you know all i want to do it , please do it for me
    This is not how this forum works; obviously your code doesn't do what you want it to do (otherwise you wouldn't be here); you can't just dump everything here, demand us to do it for you while you throw your hands up in the air. At least you could tell us what part of the code doesn't work and what you expect it to do ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,785
    Blog Entries
    7
    Rep Power
    21

    Default Re: how to do it with array !

    @OP: I removed your other (identical) thread; stick to this thread and wait for an answer (if any); note that it is Sunday today and the forums are very quiet during the weekends; also read my previous reply again.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: how to do it with array !

    For the triangle, you could go through the rows and print out a substring of the data in the columns, the length of the substring getting larger for every row. For the sum, you would go through each column and add all of the data in the rows, then print. This can be done with simple for loops.

    EDIT: I have written a program with the following output:

    Java Code:
    222
    333
    444
    
    2
    33
    444
    
    999
    
    222
    33
    444
    Sorry for the code tags, it just looks better

    If that is what you needed I can gladly help you, you just need to put in the effort
    Last edited by zFollette; 01-12-2014 at 06:53 PM.

  9. #9
    Dlovan is offline Member
    Join Date
    Jan 2014
    Posts
    16
    Rep Power
    0

    Default Re: how to do it with array !

    Quote Originally Posted by JosAH View Post
    This is not how this forum works; obviously your code doesn't do what you want it to do (otherwise you wouldn't be here); you can't just dump everything here, demand us to do it for you while you throw your hands up in the air. At least you could tell us what part of the code doesn't work and what you expect it to do ...

    kind regards,

    Jos
    what !!!! if i know how to write code then if i mistake in the code i can correct my code , but tell me if i don't no how to write code and i haven't any idea how to write code !!!!!

    i hope another one can help me

  10. #10
    Dlovan is offline Member
    Join Date
    Jan 2014
    Posts
    16
    Rep Power
    0

    Default Re: how to do it with array !

    Quote Originally Posted by zFollette View Post
    For the triangle, you could go through the rows and print out a substring of the data in the columns, the length of the substring getting larger for every row. For the sum, you would go through each column and add all of the data in the rows, then print. This can be done with simple for loops.

    please don't tell me how do it , i put here my code if you know how do it please do it and put it here



    regards

  11. #11
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: how to do it with array !

    Quote Originally Posted by Dlovan View Post
    please don't tell me how do it , i put here my code if you know how do it please do it and put it here



    regards
    Java Code:
    Toolkit t = Toolkit.getDefaultToolkit();
            
            for (int i = 0; i < 100; i++) {
                t.beep();
            }

  12. #12
    Dlovan is offline Member
    Join Date
    Jan 2014
    Posts
    16
    Rep Power
    0

    Default Re: how to do it with array !

    it doesn't compile !!


    Note : i use textpad editor for writing code .

  13. #13
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: how to do it with array !

    Quote Originally Posted by Dlovan View Post
    it doesn't compile !!


    Note : i use textpad editor for writing code .
    Add this import:

    Java Code:
    import java.awt.Toolkit;

  14. #14
    Dlovan is offline Member
    Join Date
    Jan 2014
    Posts
    16
    Rep Power
    0

    Default Re: how to do it with array !

    just tell me this code what to do it for me nothing is change when i run my code !!!! please please do it for your self then put it here .

    regards

  15. #15
    pj6444 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    165
    Rep Power
    2

    Default Re: how to do it with array !

    Here's how you can do it...

    Java Code:
    public class Thing {
    
        public static void main(String[] agrs) {
            System.out.println("Nobody will do it for you.");
        }
    
    }

  16. #16
    Dlovan is offline Member
    Join Date
    Jan 2014
    Posts
    16
    Rep Power
    0

    Default Re: how to do it with array !

    Quote Originally Posted by pj6444 View Post
    Here's how you can do it...

    Java Code:
    public class Thing {
    
        public static void main(String[] agrs) {
            System.out.println("Nobody will do it for you.");
        }
    
    }
    yeah you write i try to it and found it best for me than your or other code

    regards

  17. #17
    pj6444 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    165
    Rep Power
    2

    Default Re: how to do it with array !

    Quote Originally Posted by Dlovan View Post
    yeah you write i try to it and found it best for me than your or other code

    regards
    I don't really understand what you're saying?

  18. #18
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: how to do it with array !

    Quote Originally Posted by pj6444 View Post
    I don't really understand what you're saying?
    Did he completely miss the system beep loop I gave him?

  19. #19
    Dlovan is offline Member
    Join Date
    Jan 2014
    Posts
    16
    Rep Power
    0

    Default Re: how to do it with array !

    hahah it doesn't matter the best thing for me like this
    Java Code:
    System.out.println("Stay Here and not doing anything"); :D

  20. #20
    Dlovan is offline Member
    Join Date
    Jan 2014
    Posts
    16
    Rep Power
    0

    Default Re: how to do it with array !

    i try and found it look my friend for find triangle use this code

    Java Code:
     	int i,j,c=0;
    		for(i=0;i<3;i++)
    		{
    		for(j=0;j<3;j++)
    		{
    		if(i<=j)
    		{
    		c=c+x[i][j];
    		}
    		}
    		}
    	System.out.println("The Sum of triangle  is:"+c);
    i hope all the members gain it

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 15
    Last Post: 05-14-2012, 01:42 PM
  2. Replies: 0
    Last Post: 05-12-2011, 08:04 PM
  3. Replies: 23
    Last Post: 09-07-2010, 09:12 PM
  4. Replies: 2
    Last Post: 09-06-2010, 02:03 AM
  5. Replies: 1
    Last Post: 03-31-2009, 07:40 AM

Posting Permissions

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