How to find max and min both non-zero values from a set of values in an array...
We want max value =11 and min value=2
Please help me out I am stuck here...
SystemAdmin 110000D4XK1883 Posts
Re: Non zero minimum value2012-12-25T23:28:33ZThis is the accepted answer. This is the accepted answer.You can use the min and max operators with a conditional statement in their scope:
range R = 1..7; int A[R] = [0, 2, 0, 5, 8, 0, 11]; int minA = min(r in R : A[r] != 0) A[r]; int maxA = max(r in R : A[r] != 0) A[r];
StefanoUpdated on 2014-03-26T05:51:41Z at 2014-03-26T05:51:41Z by iron-man