Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- //workshop dodati
- void zadatak1(){
- float broj1, broj2;
- broj1=7.3;
- float *pok;
- pok=&broj1;
- cout<<"*pok : "<<*pok<<endl;
- broj2=*pok;
- cout<<"broj2 : "<<broj2<<endl;
- cout<<"&broj1: "<<&broj1<<endl;
- }
- void zbroji(int*a, int*b, int*c){
- *c=*a+*b;
- }
- int *zbroji2(int*a,int*b){
- int *pok=new int;
- (*a)++;(*b)++;
- *pok=*a+*b;
- return pok;
- }
- void zamjeni(int*p1,int*p2){
- int *t=new int;
- *t=*p1;
- *p1=*p2;
- *p2=*t;
- delete t;
- t=NULL;
- }
- void zadatak2i3(){
- int *a=new int,*b=new int, *c=new int;
- cout<<"Unesi a i b : "<<endl;
- cin>>*a>>*b;
- zbroji(a,b,c);
- cout<<"a+b=c : : :"<<*c<<endl;
- c=zbroji2(a,b);
- cout<<"a++ b++, a+b=c : "<<*c<<endl;
- cout<<"Zamjeni : : :"<<endl;
- int aa=*a, bb=*b;
- delete a,b,c;
- c=NULL;
- a=&aa, b=&bb;
- zamjeni(a,b);
- cout<<"aa= "<<aa<<"bb= "<<bb<<endl;
- a=NULL,b=NULL;
- }
- void unos_double(double *niz){
- for (int i=0; i<10; i++){
- cout<<"Unesi ["<<i+1<<"] ćlan niza:"<<endl;
- cin>>niz[i];
- }
- }
- void zadatak4(){
- double niz[10];
- double *dob=niz; //double *dob = &niz[0];
- unos_double(dob);
- cout<<"4 element niza a): "<<*(niz+4)<<endl;
- cout<<"4 element niza b): "<<niz[3]<<endl;
- cout<<"4 element niza c): "<<dob[3]<<endl;
- cout<<"4 element niza d): "<<*(dob+4)<<endl;
- cout<<"Adrese elementa niza: "<<endl;
- int b=0;
- while(b<10){
- cout<<dob+b<<endl;
- b++;
- }
- b=0;
- cout<<"Vrijednosti niza : "<<endl;
- while(b<10){
- cout<<b<<") : "<<*(dob+b)<<endl;
- b++;
- }
- }
- void main(){
- zadatak1();
- zadatak2i3();
- zadatak4();
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement