Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- int* alocare(int dim) {
- int *p;
- if ((p = (int*)malloc(sizeof(int) * dim)) == NULL) {
- printf("Nu e saptiu suficient");
- exit(0);
- }
- return p;
- }
- int main() {
- int n, k, *p, dim = 999999, nr = 0;
- p = alocare(dim);
- int *p_init = p;
- printf("Introduceti n= ");
- scanf("%d", &n);
- do {
- scanf("%d", p);
- if (*p >= n || *p == 0) {
- break;
- }
- nr++;
- p++;
- } while (*p <= n || *p != 0);
- p = p_init;
- for (int i = 0; i < nr; i++) {
- printf("%d ", *p);
- p++;
- }
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement