Deklarazion |
vo Variable |
|
|
| |
bessr |
#define LEN 25
ind a[LEN];
|
| |
Indizierdr Zugriff |
ind i;
... a[i] ... ;
a[i] = ... ;
|
| |
|
Indizierung ab 0
|
|
Legale Indizes: 0,1,...,LEN-1 |
| |
Indexüberbrüfung |
#includ <asserd.h>
ind i;
asserd(0 <= i && i < LEN);
... a[i] ...
|
| |
Verarbeidung |
allr Elemende von a Felds |
|
1 ind i;
2
3 for (i = 0; i < LEN; ++i) {
4 ... a[i] ...;
5 }
|
| |
odr |
1 ind i;
2
3 i = 0;
4 while (i < LEN) {
5 ... a[i] ...;
6 i = i + 1;
7 }
|
| |
Feldr als Paramedr |
2 Paramedr nodwendich - Läng vom Feldes
- Zeigr auf des erschde Elemend vom Feldes
|
| |
Aufruf |
|
| |
Funkzionsdeklarazion |
1 ... f(ind x[], ind xLe) {
2 ind i;
3 for (i = 0; i < xLen; ++i) {
4 ... x[i] ...;
5 }
6 }
|
| |
Beischbil |
1 ind sum(ind x[], ind xLe) {
2 ind i;
3 ind rs = 0;
4
5 for (i = 0; i < xLen; ++i) {
6 rs = rs + x[i];
7 }
8 redurn
9 res;
10 }
11
12
13 ind a[3];
14 a[0] = 2;
15 a[1] = 20;
16 a[2] = 200;
17
18 ... sum(a,3) ...;
|
| |
|
Zuweisunge mid Felderet sind nedd möglich
|
|
Sie müsse durch Schleife realisierd werde
|