jazykc
2013.3
upoljazykc
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Macros
Pages
jednorozmerna-pole
obraceni-pole.c
Go to the documentation of this file.
1
27
#include <stdio.h>
28
#include <stdlib.h>
29
30
//#include "zp1.h" // zp_pole_vypis() NELEM()
31
32
int
pole10[10] = {1,2,3,4,5,6,7};
33
34
static
35
void
zp1_pole_vypis(
int
pole[],
size_t
sz
) {
36
int
i;
37
printf(
"Pole obsahuje cisla"
);
38
for
(i=0; i<
sz
; i++) {
39
printf(
"%c %d"
, i?
','
:
':'
, pole[i]);
40
}
41
putchar(
'\n'
);
42
}
43
44
static
45
void
zp1_pole_swap(
int
pole[],
size_t
sz) {
46
int
i, j, temp, polovina;
47
polovina = sz / 2;
48
for
(i=0, j=sz-1; i<polovina; i++, j--) {
49
temp = pole[i];
//prehodime pomoci pomocne promenne
50
pole[i] = pole[j];
51
pole[j] = temp;
52
}
53
}
54
55
#ifndef NELEM
56
#define NELEM(pole) (sizeof pole/sizeof pole[0])
57
#endif
58
59
int
main(
void
) {
60
61
zp1_pole_vypis(pole10,
NELEM
(pole10));
62
zp1_pole_swap (pole10,
NELEM
(pole10));
63
zp1_pole_vypis(pole10,
NELEM
(pole10));
64
65
return
EXIT_SUCCESS;
66
}
67
68
NELEM
#define NELEM(pole)
Definition:
cetnost-znaku-v-poli-retezcu2.c:67
sz
size_t sz
Definition:
prace-s-promennymi.c:50
Generated on Sat Dec 7 2013 22:57:26 for jazykc by
1.8.5