Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. const int n = 10;
  7. int vivodA (int *A, int n){ //n - numberOfElements, число чисел
  8. for (int i=0; i<n; ++i){
  9. A[i]=i;
  10. cout<<A[i]<<" ";
  11. }
  12. }
  13.  
  14. int vivodB (int *B, int k ){ // B в 2 раза короче, чем А, зависит от сколько А
  15. for (int i=0; i < k; ++i){
  16. B[i]=i;
  17. cout<<B[i]<<" ";
  18. }
  19. }
  20.  
  21. int vivodC (int *C, int f){
  22. for (int i=f; i <n; ++i){
  23. C[i]=i;
  24. cout<<C[i]<<" ";
  25. }
  26. }
  27.  
  28. int splitA( int *A, int *B, int *C, int n){
  29. for (int i=0; i < n/2; ++i){
  30. B[i]=A[n-n+i];
  31. C[i]=A[n-n/2+i];
  32.  
  33.  
  34. cout<<B[i]<<C[i]<<" "<<'\n';
  35.  
  36. }
  37.  
  38.  
  39. }
  40.  
  41. int main()
  42. {
  43. const int n = 10;
  44.  
  45. int* A = new int[n];
  46. int* B = new int[n/2];
  47. int* C = new int[n/2];
  48.  
  49. vivodA ( A, n);
  50. cout << '\n';
  51. vivodB ( B, n/2);
  52. cout << '\n';
  53. vivodC ( C, n/2);
  54.  
  55. cout << '\n';
  56. cout << '\n';
  57.  
  58. splitA( A, B ,C , n);
  59.  
  60.  
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement