Miten alla oleva koodi toteutetaan while ja do-while rakenteella??
oli kokeessa ois kiva tietää menikö sinne päinkään.
int f=0;
for(int i=N-1; i >=0; i--)
if( a[i] > a[f])
f = i;
oli kokeessa ois kiva tietää menikö sinne päinkään.
int f=0;
for(int i=N-1; i >=0; i--)
if( a[i] > a[f])
f = i;
Vastaukset 2
Vanhimmat
while:
int f = 0;
int i = N - 1;
while (i >= 0) {
if (a[i] > a[f])
f = i;
i--;
}
do-while:
int f = 0;
int i = N - 1;
if (i >= 0) /* varmuuden vuoksi */
do {
if (a[i] > a[f])
f = i;
i--;
} while (i >= 0);
kiitos, taisi sittenkin mennä sinne päin:)