Ak Java Freak
Posts : 23 Join date : 2009-02-07
| Subject: java count the occurance of number inside the offset Fri Apr 03, 2009 12:44 am | |
| - Code:
-
public class sample { public static void main(String args[]) { int num[]= {1,2,5,4,5,6,7,8,9,5}; int index1, count = 0, find = 0;
for(index1 = 0; index1 < num.length; index1++) { count = 0; for(int index2 = 0; index2 < num.length; index2++) { if(num[index2]==num[index1]) { find = num[index2]; count++; } } System.out.println("i found " + find + " " + count + " time(s) inside the offset"); }
} }
| |
|