xor() finished

This commit is contained in:
artem.didytschuk 2020-08-31 22:48:37 +02:00
parent 1be004f517
commit 9e68485283
1 changed files with 13 additions and 1 deletions

View File

@ -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;
}
/**