-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddprtns.cpp
More file actions
38 lines (31 loc) · 1.21 KB
/
addprtns.cpp
File metadata and controls
38 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
int main ()
{
using namespace std;
//Zadefinovanie pola
double wages [3] = {10000.0, 20000.0, 30000};
short stacks [3] = {3, 2, 1};
//Dva sposoby ziskania adresy pola:
double * pw = wages;
short * ps = &stacks[0];
// Praca s dynamickym polom
cout << "pw = " << pw << " a *pw = " << *pw << endl;
pw = pw + 1; // inkrementuje ukazovatel
cout << "K adrese pola sme pripocitali 1" << endl;
cout << "pw = " << pw << " a *pw = " << *pw << endl << endl;
//dtto pre ps
cout << "ps = " << ps << " a *ps = " << *ps << endl;
ps = ps + 1; // inkrementuje ukazovatel
cout << "K adrese pola sme pripocitali 1" << endl;
cout << "ps = " << ps << " a *ps = " << *ps << endl << endl;
//Pristup k prvkom pola
cout << "Zpristupnenie dvoch prvkov pola pomocou zapisu pola:" << endl;
cout << "stacks[0] = " << stacks[0]
<< " a stacks[1] = " << stacks[1] << endl;
cout << "Zpristupnenie dvoch prvkov pola pomocou zapisu ukazovatela:" << endl;
cout << "*stacks = " << *stacks
<< " a *(stacks+1) = " << *(stacks + 1)<< endl;
cout << sizeof wages << " je velkost pole wages" << endl;
cout << sizeof pw << " je velkost ukazovatela pw" << endl << endl;
return 0;
}