Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // problem4.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #define MAXSIZE 20
- void inputArr(int *arr, int *size);
- void possitiveA(int x[], int *arrB, int *size, int n);
- int _tmain(int argc, _TCHAR* argv[])
- {
- int A[MAXSIZE], B[MAXSIZE], n, sizeofB;
- sizeofB = 0;
- inputArr(A, &n);
- possitiveA(A, B, &n, n);
- for (int i = n - 1; i>=0;i--)
- {
- printf("%d\n", *(B + i));
- }
- return 0;
- }
- void inputArr(int *arr, int *size)
- {
- int i;
- do{
- printf("Enter N: \n");
- scanf_s("%d", size);
- } while ((*size<1) || (*size>MAXSIZE));
- for (i = 0; i < *size; ++i)
- {
- printf("Enter num for %d possition: ", i + 1);
- scanf_s("%d", arr++);
- }
- }
- void possitiveA(int x[], int *arrB, int *size, int n)
- {
- int i;
- for (i = 0; i<n; i++)
- {
- if (*x< 0)
- {
- *arrB++ = *x++;
- }
- else
- {
- (*size)--;
- *x++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement