Guest User

Untitled

a guest
Jan 6th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. //h)
  6. void teigiamas(int* x){
  7. if(*x>0)
  8. cout<<"Teigiamas"<<endl;
  9. else if(*x<0){
  10. cout<<"Neigiamas"<<endl;
  11. *x=0;}
  12. else
  13. cout<<"Nei neigiamas, nei teigiamas"<<endl;
  14. }
  15.  
  16. int main(){
  17. //a Sukurkite 2 sveikojo tipo kintamuosius), f)sukuriame temp ir rodykle i p2
  18. int x, y, temp, *p1, *p2;
  19.  
  20. //b) sukurkite rodykle kuri saugotu kintamoju adresa
  21. p1=&x;
  22.  
  23. //c)naudodami rodykle p1, kintamajam priskiriam 99
  24. *p1=99;
  25.  
  26. //d) kintamojo x reiksme atspausdinkite dviem budais
  27. cout<<"d) "<<x<<" "<<*p1<<endl;
  28.  
  29. //e) nukreipkite rodykle p1 i kintamyji y ir sio reiksme nustatykit -300
  30. p1=&y;
  31. *p1=-300;
  32.  
  33. //g) sukeiciamos reiksmes naudojant temp
  34. p2=&x;
  35. temp=*p2;
  36. *p2=*p1;
  37. *p1=temp;
  38. cout<<"g) "<<"x= "<<x<<" "<<"y= "<<y<<endl;
  39.  
  40. //h)
  41. cout<<"h)"<<endl;
  42. cout<<"x "; teigiamas(p2);
  43. cout<<"y "; teigiamas(p1);
  44.  
  45. cout<<"i) "<<"x= "<<*p2;
  46. p2=&y;
  47. cout<<"y= "<<*p2<<endl;
  48.  
  49.  
  50. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment