# problem sum of the column matrix of the smallest

Page 1 of 1

## 4 Replies - 662 Views - Last Post: 03 May 2013 - 07:15 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=319984&amp;s=88426182e127507c04fad7b66dd1bf43&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 cakcukz

• New D.I.C Head

Reputation: 0
• Posts: 3
• Joined: 30-April 13

# problem sum of the column matrix of the smallest

Posted 30 April 2013 - 08:30 PM

I have a problem with the sum of random numbers from the smallest to the largest, but the result without changing the order of the numbers.
example: 9 1 3 7 4 result will be 29 1 4 15 8
please its support
thankz

like this, but this the result of this sum is not in accordance with the order of the matrix colomnya, but from the smallest number to the largest

```public  class matriks{
@SuppressWarnings("empty-statement")
public static void main (String[] args) {
int rows = 4;
int cols = 5;
int[][] matrix = {
{ 5, 9, 8, 10, 1 },
{ 9, 3, 10, 1, 8 },
{ 9, 4, 5, 8, 6 },
{ 4, 8, 8, 7, 2 }
};
System.out.println();

for (int i=0; i<rows; i++)
{ for (int j=0;j<cols;j++) {
if (i==0){
matrix[i][j]=0;
System.out.print(matrix[i][j]+" ");
}
else{
System.out.print( matrix[i][j]+" ");
}
}
System.out.println();
}
System.out.println();

int[] array1 = {  matrix[1][0], matrix[2][0], matrix [3][0] };
int min1=100;
int baris1;

for(int i=0; i<array1.length; i++){

if(array1[i]<min1){
min1=array1[i];
baris1=i;
//             System.out.println("Baris :"+baris1);
}
}
System.out.println("Nilai terkecilnya M1 adalah "+min1);

int temp;
//     System.out.print("Nilai urutan job1=0 ");

for(int i=1; i<array1.length; i++){
for(int j=array1.length-1; j>=i; j--){
if(array1[j]<array1[j-1]){
temp=array1[j];
array1[j]=array1[j-1];
array1[j-1]=temp;
}

}
}
int a = (+min1);
for (int i=0;i<array1.length;i++) {
// System.out.print( +array1[i]);

if(+array1[i]>+min1){
a = (+array1[i])+(+a);
}
System.out.println(+a);

}
for (int i=0;i<array1.length;i++) {
}
System.out.println();
```

Is This A Good Question/Topic? 0

## Replies To: problem sum of the column matrix of the smallest

### #2 GregBrannon

• D.I.C Lover

Reputation: 2246
• Posts: 5,333
• Joined: 10-September 10

## Re: problem sum of the column matrix of the smallest

Posted 01 May 2013 - 02:51 AM

I don't think anyone understands what you're asking. This:

"example: 9 1 3 7 4 result will be 29 1 4 15 8"

is completely mysterious.
Was This Post Helpful? 0

### #3 cakcukz

• New D.I.C Head

Reputation: 0
• Posts: 3
• Joined: 30-April 13

## Re: problem sum of the column matrix of the smallest

Posted 03 May 2013 - 12:07 PM

GregBrannon, on 01 May 2013 - 02:51 AM, said:

I don't think anyone understands what you're asking. This:

"example: 9 1 3 7 4 result will be 29 1 4 15 8"

is completely mysterious.

sequence was derived from the sum of numbers from the smallest to the largest, but it does not change the composition of numbers initially
Was This Post Helpful? 0

### #4 GregBrannon

• D.I.C Lover

Reputation: 2246
• Posts: 5,333
• Joined: 10-September 10

## Re: problem sum of the column matrix of the smallest

Posted 03 May 2013 - 03:25 PM

Showing the derivation of that result would have been helpful, but you can keep it as mysterious as you like. If you'd like help, give an explanation we can understand. The sequence

9, 1, 3, 7, 4

does not appear in the matrix you posted, and summing them to get 29 is impossible.

What you've described sounds like ordering the numbers from smallest to largest and then adding them somehow. I don't get the "not change the composition" part.
Was This Post Helpful? 0

### #5 pbl

• There is nothing you can't do with a JTable

Reputation: 8365
• Posts: 31,956
• Joined: 06-March 08

## Re: problem sum of the column matrix of the smallest

Posted 03 May 2013 - 07:15 PM

cakcukz, on 30 April 2013 - 11:30 PM, said:

I have a problem with the sum of random numbers from the smallest to the largest, but the result without changing the order of the numbers.
example: 9 1 3 7 4 result will be 29 1 4 15 8

Explain how you go from 9 1 3 7 4 to 29 1 4 15 8
Was This Post Helpful? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }