forked from IF-LK-2020/array
xor() finished
This commit is contained in:
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.
|
* Für ein leeres Array wird <code>false<code> zurück gegeben.
|
||||||
*/
|
*/
|
||||||
public boolean xor( boolean[] pArray ) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user