Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.
public int scoresAverage(int[] scores) {
int result=0;
int len=scores.length;
int lenHalf=len/2;
int sumEven=0;
int sumOdd=0;
for(int i=0;i<lenHalf;i++){
sumEven=(scores[i]+scores[i+1])/2;
//result=sumeEven;
//return result;
}
for(int i=lenHalf;i<len;i++){
sumOdd=(scores[i]+scores[i+1])/2;
// result=sumeOdd;
//return result;
}
if(sumOdd>sumEven){
return sumOdd;
}
else{
return sumEven;
}
}
return result;
}
}
public int scoresAverage(int[] scores) {
int result=0;
int len=scores.length;
int lenHalf=len/2;
int sumEven=0;
int sumOdd=0;
for(int i=0;i<lenHalf;i++){
sumEven=(scores[i]+scores[i+1])/2;
//result=sumeEven;
//return result;
}
for(int i=lenHalf;i<len;i++){
sumOdd=(scores[i]+scores[i+1])/2;
// result=sumeOdd;
//return result;
}
if(sumOdd>sumEven){
return sumOdd;
}
else{
return sumEven;
}
return result;
}
public int scoresAverage(int[] scores) {
int result=0;
int len=scores.length;
int lenHalf=len/2;
int sumEven=0;
int sumOdd=0;
if(len>2){
for(int i=0;i<lenHalf-1;i++){
sumEven=(scores[i]+scores[i+1])/2;
//result=sumeEven;
//return result;
}
for(int i=lenHalf;i<len-1;i++){
sumOdd=(scores[i]+scores[i+1])/2;
// result=sumeOdd;
//return result;
}
if(sumOdd>sumEven){
result=sumOdd;
return result;
}
else{
result=sumEven;
return result;
}
}
else{
if(scores[0]>scores[1]){
result=scores[0];
return result;
}
else{
result=scores[1];
return result;
}
}
}
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
Delphi: barcode reading on android platform | 1 | 51 | |
Programming Codes | 2 | 22 | |
learn programming | 8 | 42 | |
Create .bat File | 16 | 36 |
Join the community of 500,000 technology professionals and ask your questions.