Advertisement
Nannoka

Vetor tamanho definido pelo user

Jun 24th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1.     #include <stdio.h>
  2.     #include <stdlib.h>
  3.     #include <conio.h>
  4.     #include <math.h>
  5.     #include <time.h>
  6.     #include <string.h>
  7.     #include <windows.h>
  8.     #include <locale.h>
  9.    
  10.     int main()
  11.     {
  12.         int i, x;
  13.         int *v;
  14.        
  15.         printf("Informe o tamanho do vetor: ");
  16.         scanf("%d", &x);
  17.         v = (int *)malloc(x * sizeof(int));
  18.             for (i =0; i < x; ++i)
  19.             {
  20.                 v[i] = i;
  21.             }
  22.             for (i = 0; i < x; ++i)
  23.             {
  24.                 printf("%d", v[i]);
  25.             }
  26.             printf("\n");
  27.             free (v);
  28.             return 0;
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement