Advertisement
Guest User

Problem4

a guest
May 3rd, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. // problem4.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #define MAXSIZE 20
  6.  
  7. void inputArr(int *arr, int *size);
  8. void possitiveA(int x[], int *arrB, int *size, int n);
  9.  
  10. int _tmain(int argc, _TCHAR* argv[])
  11. {
  12.     int A[MAXSIZE], B[MAXSIZE], n, sizeofB;
  13.     sizeofB = 0;
  14.     inputArr(A, &n);
  15.     possitiveA(A, B, &n, n);
  16.  
  17.     for (int i = n - 1; i>=0;i--)
  18.     {
  19.         printf("%d\n", *(B + i));
  20.     }
  21.  
  22.     return 0;
  23. }
  24. void inputArr(int *arr, int *size)
  25. {
  26.     int i;
  27.     do{
  28.         printf("Enter N: \n");
  29.         scanf_s("%d", size);
  30.     } while ((*size<1) || (*size>MAXSIZE));
  31.     for (i = 0; i < *size; ++i)
  32.     {
  33.         printf("Enter num for %d possition: ", i + 1);
  34.         scanf_s("%d", arr++);
  35.     }
  36.  
  37.  
  38. }
  39. void possitiveA(int x[], int *arrB, int *size, int n)
  40. {
  41.     int i;
  42.  
  43.  
  44.     for (i = 0; i<n; i++)
  45.     {
  46.         if (*x< 0)
  47.         {
  48.             *arrB++ = *x++;
  49.         }
  50.         else
  51.         {
  52.             (*size)--;
  53.             *x++;
  54.         }
  55.  
  56.     }
  57.  
  58.  
  59.  
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement