Stack st = new Stack<>(); st.add(“5"); st.add(“2"); st.add(“3"); st.add(“6"); st.remove(Collections.min(st));
Elements of stack
Solution of task
int[] a = new int[st.size()];
int min = st.get(0);
for (int i = 0; i < st.size(); i++) {
if (min > st.get(i)) {
min = st.get(i);
}
}
int count = 0;
for (int i = 0; i < st.size(); i++) {
if (min == st.get(i)) {
continue;
} else {
a[count] = st.get(i);
}
System.out.println(a[count]);
count ++;
}
Do'stlaringiz bilan baham: |