Advertisement
pseudocreator

wsdobar

Mar 28th, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. //workshop dodati
  7.  
  8. void zadatak1(){
  9.         float broj1, broj2;
  10.         broj1=7.3;
  11.         float *pok;
  12.         pok=&broj1;
  13.         cout<<"*pok : "<<*pok<<endl;
  14.         broj2=*pok;
  15.         cout<<"broj2 : "<<broj2<<endl;
  16.         cout<<"&broj1: "<<&broj1<<endl;
  17. }
  18. void zbroji(int*a, int*b, int*c){
  19.         *c=*a+*b;
  20. }
  21. int *zbroji2(int*a,int*b){
  22.         int *pok=new int;
  23.         (*a)++;(*b)++;
  24.         *pok=*a+*b;
  25.         return pok;
  26. }
  27. void zamjeni(int*p1,int*p2){
  28.         int *t=new int;
  29.         *t=*p1;
  30.         *p1=*p2;
  31.         *p2=*t;
  32.         delete t;
  33.         t=NULL;
  34. }
  35. void zadatak2i3(){
  36.         int *a=new int,*b=new int, *c=new int;
  37.         cout<<"Unesi a i b : "<<endl;
  38.         cin>>*a>>*b;
  39.         zbroji(a,b,c);
  40.         cout<<"a+b=c : : :"<<*c<<endl;
  41.         c=zbroji2(a,b);
  42.         cout<<"a++ b++, a+b=c : "<<*c<<endl;
  43.         cout<<"Zamjeni : : :"<<endl;
  44.         int aa=*a, bb=*b;
  45.         delete a,b,c;
  46.         c=NULL;
  47.         a=&aa, b=&bb;
  48.         zamjeni(a,b);
  49.         cout<<"aa= "<<aa<<"bb= "<<bb<<endl;
  50.         a=NULL,b=NULL;
  51. }
  52.  
  53. void unos_double(double *niz){
  54.         for (int i=0; i<10; i++){
  55.                 cout<<"Unesi ["<<i+1<<"] ćlan niza:"<<endl;
  56.                 cin>>niz[i];
  57.         }
  58. }
  59. void zadatak4(){
  60.        
  61.         double niz[10];
  62.         double *dob=niz; //double *dob = &niz[0];
  63.         unos_double(dob);
  64.         cout<<"4 element niza a): "<<*(niz+4)<<endl;
  65.         cout<<"4 element niza b): "<<niz[3]<<endl;
  66.         cout<<"4 element niza c): "<<dob[3]<<endl;
  67.         cout<<"4 element niza d): "<<*(dob+4)<<endl;
  68.         cout<<"Adrese elementa niza: "<<endl;
  69.         int b=0;
  70.         while(b<10){
  71.                 cout<<dob+b<<endl;
  72.                 b++;
  73.         }
  74.         b=0;
  75.         cout<<"Vrijednosti niza : "<<endl;
  76.         while(b<10){
  77.                 cout<<b<<") : "<<*(dob+b)<<endl;
  78.                 b++;
  79.         }
  80. }
  81.  
  82. void main(){
  83.         zadatak1();
  84.         zadatak2i3();
  85.         zadatak4();
  86.        
  87. system("PAUSE");
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement