![]() |
Re: [Java] Arrayinhalt gruppieren
echt der Hammer... das war dem Lehrer heute noch zu redundant.. naja habs noch mal angepasst, dann wars in Ordnung:
Code:
private void checkNull(final long[] zahlen)throws IllegalArgumentException{
if (zahlen == null) { throw new IllegalArgumentException(); } } boolean zahlgerade(final long zahl, final boolean gerade){ return (zahl%2==0==gerade); } long[] gruppiert(final long[] zahlen) throws IllegalArgumentException { checkNull(zahlen); int pos = 0; final long[] result = new long[zahlen.length]; for(int e=1;e<=2;e++){ for (int i = 0; i < zahlen.length; i++){ if (zahlgerade(zahlen[i],e==1)){ result[pos++] = zahlen[i]; } } } return result; } |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:56 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz