Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <malloc.h>
- int main(){
- int n;
- printf("Input size of array: ");
- scanf("%d", &n);
- int* massive = (int*)malloc(sizeof(int)*n);
- printf("Input elements of array: ");
- int zeros = 0;
- int c = 0;
- for(int i = 0; i < n; ++i){
- int buf;
- scanf("%d", &buf);
- if(!buf)
- ++zeros;
- else
- massive[c++] = buf;
- }
- for(int i = c; i < n; ++i)
- massive[i] = 0;
- printf("Answers array: ");
- for(int i = 0; i < n; ++i)
- printf("%d ", massive[i]);
- printf("\n");
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement