Java - Sorting results -
i have equation : a = b^2 + 4*c^2
i change value of 'b' , 'c' this: b=1,2,3,4,5,...
, c=1,2,3,4,5,...
, put them in equation.
i want create table of results (as output), this:
b c 1 1 5 1 2 17 2 1 8 2 2 20 4 1 20 ........
however, want have table sorted smallest value of towards biggest. note can occur different pairs of b , c give same a. want create table 10 different values of a.
my problem don't know how 'link' value proper value of b , c, when try sort table
you may create class represent 3 values , sort.
class tuple implement comparable<tuple>{ int a, b, c; //.... int compareto(tuple tuple) { return integer.compare(a, tuple.a); } } tuple[] tuples; // ... arrays.sort(tuples);
Comments
Post a Comment