Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int my_swap(int *a,int *b);
- int main(){
- int x=0,y=0;
- int *X=&x,*Y=&y;
- cin >> x;
- cin >> y;
- cout << "Value of x: " << *X << endl;
- cout << "Value of y: " << *Y << endl;
- cout << *X+*Y << endl;
- int n=0;
- cin >> n;
- int a[100];
- // int *a = (int*)malloc(sizeof(int)*n);
- for(int i = 0; i < n; i++)
- {
- cin >> a[i];
- }
- for(int i = n-1;i>=0;i--){
- cout << *(a+i) << " ";
- }
- cout << endl;
- cout << "Now without for HEHE:" << endl;
- int *b = (a+n);
- int *c = a;
- while(c!=b){
- cout << *c << " ";
- c=c+1;
- }
- cout << endl;
- b = (a+n-1);
- c = a;
- while(b>=c){
- cout << *b << " ";
- b=b-1;
- }
- //free(a);
- cout << endl;
- my_swap(&x,&y);
- cout << "Value of x: " << *X << endl;
- cout << "Value of y: " << *Y << endl;
- return 0;
- }
- int my_swap(int *a,int *b){
- int c = *a;
- *a = *b;
- *b = c;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement