Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Michał Kurpiński
- #include <iostream>
- using namespace std;
- void zeruj1(int a,int b)
- {
- cout<<"przed wyzerowaniem a="<<a<<" b="<<b;
- a=0;
- b=0;
- cout<<" po wyzerowaniu a="<<a<<",b="<<b;
- }
- void zeruj2(int &a,int &b)
- {
- cout<<"przed wyzerowaniem a="<<a<<" b="<<b;
- a=0;
- b=0;
- cout<<" po wyzerowaniu a="<<a<<",b="<<b;
- }
- int main()
- {
- int x=5,y=3;
- cout<<"w jaki sposob wyzerowac wartosci?"<<endl<<"1. przekazywanie przez wartosc"<<endl<<"2. przekazywanie przez referencje";
- int liczba;
- cout<<endl;
- cin>>liczba;
- switch(liczba)
- {
- case 1:
- zeruj1(x,y);
- break;
- case 2:
- zeruj2(x,y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement