The Artima Developer Community
Sponsored Link

Java Answers Forum
Newbie for loop help

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Dave Jimson

Posts: 1
Nickname: davester
Registered: May, 2003

Newbie for loop help Posted: May 31, 2003 9:14 PM
Reply to this message Reply
Advertisement
Hi,
I have to write code that takes a 2d array, overlays a 128 grid over it and takes the value of the 2d array at the grid location and assigns it to a new 2d array. This is the results I want but I can't get the for loops to do this.
array1 [2][2] = array2 [0][0]
array1 [2][4] = array2 [0][1]

my code so far is as follows:

int x = (int)Math.rint((float)width/(float)128);
array2 = new int [128][128];
for (int i = x; i < 128; i= i+x) {
   for (int j = x; j < 128; j=j+x) {
       for(int a=0; a < 128;a++){
          for (int b=0;b<128;b++){
            array1[a][b]=array2[i][j];
           }
        }
      }
   }
} 
array1 = array2;
}

Please help. Thanks

Topic: Please, help me with login Previous Topic   Next Topic Topic: String check

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use