Answer the question
In order to leave comments, you need to log in
How to arrange an array?
I have an array [2, 2, 2, 3, 3, 97] (numbers are always in ascending order).
How to make the output get 2 numbers: the first is the sum of repeated (in pairs) elements, and the second is the sum of the rest?
int a = 2 * 2 * 3 * 3;
int b = 2 * 97;
Answer the question
In order to leave comments, you need to log in
for(int i=0;i<korn.length;){
int n = korn[i];
if (i !=korn.length-1){
if (n==korn[i+1]){
cile.add(n);
i+=2;
}else{
necile.add(n);
i++;
}
}else{
necile.add(n);
i++;
}
}
if(!necile.isEmpty()){
int nec=1;
int cil=1;
for(int n:necile){
nec=n*nec;
}
for(int n:cile){
cil = n*cil;
}
Msg(context,cil+"√"+nec+" /"+sqrt,1);
}else{
Msg(context,""+sqrt,1);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question