1
I would like to generate a vector where your next position element is added to 1. For example: be a vetor[3]
, would like that v[0] = 1
and v[1] = v[0] + 1
, v[2] = v[1] + 1
and so on. How would you do that?
Follow my code for now:
#include <stdio.h>
#include<stdlib.h>
int main(){
int N, M, i;
int *v;
printf ("Entre com N: ");
scanf ("%d", &N);
printf ("Entre com M: ");
scanf ("%d", &M);
v = (int *)malloc(M * sizeof (int));
v[0] = 1;
for (i=0; i < M; ++i){
v[i]++;
printf ("%d ", v[i]);
}
}