Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pokazivac............
- int main()
- {
- int x = 8;
- int *p_x = nullptr;
- p_x = &x;
- cout << "x= " << x << endl;
- cout << "p_x= " << p_x << endl;
- cout << "&x= " << &x << endl;
- cout << "*p_x= " << *p_x << endl;
- return 0;
- }
- dina alokacija sa prezentacije......
- int main()
- {
- int *p_x = new int;
- *p_x = 10;
- cout << "na adresi " << p_x << "upisana je vrijednost " << *p_x << endl;
- delete p_x;
- p_x = nullptr;
- return 0;
- }
- ......
- int main()
- {
- int x;
- cout << "unesite velicinu: ";
- cin >> x;
- int *polje = new int[x];
- for (int i = 0; i < x; i++) {
- cout << "polje " << i << ": ";
- cin >> polje[i];
- }
- for (int i = 0; i < x; i++)
- {
- cout <<polje[i] << "\t";
- }
- delete polje;
- polje = nullptr;
- return 0;
- }
- vektori......zadatak 1 iz prezentacije..
- int main()
- {
- vector <int> vektor;
- int unos = 0;
- do {
- cout << "unestie element u vektor: ";
- cin >> unos;
- vektor.push_back(unos);
- } while (unos != 0);
- for (int i = 0; i < vektor.size(); i++) {
- cout << "element vektora na poziciji" << i << "je: " << vektor[i] << endl;
- }
- cout << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment