Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- //h)
- void teigiamas(int* x){
- if(*x>0)
- cout<<"Teigiamas"<<endl;
- else if(*x<0){
- cout<<"Neigiamas"<<endl;
- *x=0;}
- else
- cout<<"Nei neigiamas, nei teigiamas"<<endl;
- }
- int main(){
- //a Sukurkite 2 sveikojo tipo kintamuosius), f)sukuriame temp ir rodykle i p2
- int x, y, temp, *p1, *p2;
- //b) sukurkite rodykle kuri saugotu kintamoju adresa
- p1=&x;
- //c)naudodami rodykle p1, kintamajam priskiriam 99
- *p1=99;
- //d) kintamojo x reiksme atspausdinkite dviem budais
- cout<<"d) "<<x<<" "<<*p1<<endl;
- //e) nukreipkite rodykle p1 i kintamyji y ir sio reiksme nustatykit -300
- p1=&y;
- *p1=-300;
- //g) sukeiciamos reiksmes naudojant temp
- p2=&x;
- temp=*p2;
- *p2=*p1;
- *p1=temp;
- cout<<"g) "<<"x= "<<x<<" "<<"y= "<<y<<endl;
- //h)
- cout<<"h)"<<endl;
- cout<<"x "; teigiamas(p2);
- cout<<"y "; teigiamas(p1);
- cout<<"i) "<<"x= "<<*p2;
- p2=&y;
- cout<<"y= "<<*p2<<endl;
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment