31 lines
440 B
C
31 lines
440 B
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
int *count(int n){
|
|
|
|
if (n < 1) return NULL;
|
|
|
|
int *p = malloc(n * sizeof(int));
|
|
if(p == NULL) return NULL;
|
|
|
|
while (n != 0){
|
|
|
|
*(p + n-1) = n;
|
|
n --;
|
|
}
|
|
return p;
|
|
}
|
|
/*
|
|
int main(){
|
|
int *rslt = count(5123456);
|
|
int index = 0;
|
|
|
|
while(*(rslt + index)){
|
|
|
|
printf("%i, ", *(rslt + index));
|
|
index ++;
|
|
}
|
|
free(rslt);
|
|
|
|
}
|
|
*/
|