daily pastebin goal
84%
SHARE
TWEET

Untitled

a guest Sep 19th, 2018 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ~~~
  2. SWITCH POINTERS
  3.  
  4. #include<iostream>
  5. using namespace std;
  6.  
  7. int pointersswitch(int **p,int **q)
  8. {swap(*p,*q);
  9. return 0;}
  10.  
  11. int *a=new int;
  12. int *b=new int;
  13.  
  14. int main()
  15. {cout<<a<<endl<<b;
  16. cout<<endl;
  17. pointersswitch(&a,&b);
  18. cout<<a<<endl<<b;}
  19. ~~~
  20.  
  21. SWITCH DATA
  22.  
  23. #include<iostream>
  24. using namespace std;
  25. int v[3]={73,21,53};
  26. int l[3]={16,35,27};
  27. int *p; int *q;
  28.  
  29. int swapdata(int *p,int *q)
  30. {swap(*p,*q);
  31. return 0;}
  32.  
  33. int main()
  34. {
  35. for(int h=0;h<=2;h++)
  36.     {p=v+h;q=l+h;swapdata(p,q);}
  37.  
  38. for(int i=0;i<=2;i++) cout<<v[i]<<" ";cout<<endl;
  39. for(int j=0;j<=2;j++) cout<<l[j]<<" ";}
  40. ~~~
  41.  
  42. SWITCH DATA 2
  43.  
  44. #include<iostream>
  45. using namespace std;
  46. int v[3]={7,21,13}; int n1=2, n2=3;
  47. int l[4]={29,46,19,51};
  48. int *p; int *q;
  49.  
  50. int swapdata(int **p,int **q)
  51. {swap(*p,*q);
  52. return 0;}
  53.  
  54. int main()
  55. {p=v; q=l;
  56. swapdata(&p,&q);
  57. for(int i=0;i<=n1;i++)
  58.     cout<<*(q+i)<<" ";
  59. cout<<endl;
  60. for(int i=0;i<=n2;i++)
  61.     cout<<*(p+i)<<" ";}
  62. ~~~
  63.  
  64. ADUNARE
  65.  
  66. #include<iostream>
  67. using namespace std;
  68. int v[3]={7,21,13}; int n1=2, n2=3;
  69. int l[4]={29,46,19,51};
  70. int *p; int *q;
  71.  
  72. int swapdata(int **p,int **q)
  73. {swap(*p,*q);
  74. return 0;}
  75.  
  76. int main()
  77. {p=v; q=l;
  78. swapdata(&p,&q);
  79. for(int i=0;i<=n1;i++)
  80.     cout<<*(q+i)<<" ";
  81. cout<<endl;
  82. for(int i=0;i<=n2;i++)
  83.     cout<<*(p+i)<<" ";}
  84. ~~~
  85.  
  86. ADUNARE VECTOR
  87.  
  88. #include<iostream>
  89. #include<cmath>
  90. using namespace std;
  91. int a=7,b=39,p[100],q[100],v[100];
  92.  
  93. int adunare(int a, int b)
  94. {int i=0,j=0,h=0,k,m=0;
  95.  
  96. while(a>0)
  97. {p[i]=a%10;
  98. i++;
  99. a=a/10;}
  100. for(int y=0;y<i;y++) cout<<p[i]<<" ";cout<<endl;
  101. while(b>0)
  102. {q[j]=b%10;
  103. j++;
  104. b=b/10;}
  105. for(int y=0;y<j;y++) cout<<q[i]<<" ";cout<<endl;
  106. if(j>i)
  107. for(h=0;h<j-i;h++)
  108. {p[h+1]=p[h];
  109. p[h]=0;}
  110.  
  111. if(i>j)
  112. for(h=0;h<i-j;h++)
  113. {q[h+1]=q[h];
  114. q[h]=0;}
  115.  
  116. for(k=max(i,j);k>0;k--)
  117. {v[k]=p[k]+q[k];
  118. if(m==1) { v[k]++;m=0;}
  119. if(p[k]+q[k]>0)
  120.     m=1;}
  121. for(int x=0;x<max(i,j);x++)
  122.     cout<<v[x];
  123.  
  124. return 0;}
  125.  
  126. int main()
  127. {
  128.  
  129.     int i=0,j=0,h=0,k,m=0;
  130.  
  131. while(a>0)
  132. {p[i]=a%10;
  133. i++;
  134. a=a/10;}
  135. for(int y=0;y<i;y++) cout<<p[i]<<" ";cout<<endl;
  136. while(b>0)
  137. {q[j]=b%10;
  138. j++;
  139. b=b/10;}
  140. for(int y=0;y<j;y++) cout<<q[i]<<" ";cout<<endl;
  141. if(j>i)
  142. for(h=0;h<j-i;h++)
  143. {p[h+1]=p[h];
  144. p[h]=0;}
  145.  
  146. if(i>j)
  147. for(h=0;h<i-j;h++)
  148. {q[h+1]=q[h];
  149. q[h]=0;}
  150.  
  151. for(k=max(i,j);k>0;k--)
  152. {v[k]=p[k]+q[k];
  153. if(m==1) { v[k]++;m=0;}
  154. if(p[k]+q[k]>0)
  155.     m=1;}
  156. for(int x=0;x<max(i,j);x++)
  157.     cout<<v[x];
  158. }
  159. ~~~
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top