forked from IF-LK-2020/array
xor() finished
This commit is contained in:
parent
1be004f517
commit
9e68485283
14
Arrays.java
14
Arrays.java
|
@ -217,7 +217,19 @@ public class Arrays {
|
|||
* Für ein leeres Array wird <code>false<code> zurück gegeben.
|
||||
*/
|
||||
public boolean xor( boolean[] pArray ) {
|
||||
return true;
|
||||
if( pArray.length == 0 ) {
|
||||
return false;
|
||||
}
|
||||
int sum =0;
|
||||
for(int i=0;i<pArray.length;i++){
|
||||
if(pArray[i]== true){
|
||||
sum++;
|
||||
}
|
||||
}
|
||||
if(sum != 1){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue