fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(){
  5. int n,m,i;
  6. int *a;
  7. scanf("%d",&n);
  8. a = (int *)malloc(sizeof(int)*n);
  9. if(a == NULL){
  10. printf("ERROR\n");
  11. return 0;
  12. }
  13. for(i=0;i<n;i++){
  14. a[i] = i + 1;
  15. }
  16. for(i=0;i<n;i++){
  17. printf("%d ",a[i]);
  18. }
  19. printf("\n");
  20. free(a);
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5280KB
stdin
4
stdout
1 2 3 4