#include <stdio.h>
#include <stdlib.h>
int* copia(int *vet, int tam) {
int *retorno
= malloc(tam
* sizeof(int)); for(int i = 0; i < tam; i++)
retorno[i] = vet[i];
return retorno;
}
int main(void) {
int tam = 3;
int *vet
= malloc(tam
* sizeof(int)); vet[0] = 1;
vet[1] = 2;
vet[2] = 3;
int *novo = copia(vet, tam);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCogY29waWEoaW50ICp2ZXQsIGludCB0YW0pIHsKICAgIGludCAqcmV0b3JubyA9IG1hbGxvYyh0YW0gKiBzaXplb2YoaW50KSk7CiAgICBmb3IoaW50IGkgPSAwOyBpIDwgdGFtOyBpKyspCiAgICAgICAgcmV0b3Jub1tpXSA9IHZldFtpXTsKICAgIHJldHVybiByZXRvcm5vOwp9CgppbnQgbWFpbih2b2lkKSB7CglpbnQgdGFtID0gMzsKICAgIGludCAqdmV0ID0gbWFsbG9jKHRhbSAqIHNpemVvZihpbnQpKTsKICAgIHZldFswXSA9IDE7CiAgICB2ZXRbMV0gPSAyOwogICAgdmV0WzJdID0gMzsKCWludCAqbm92byA9IGNvcGlhKHZldCwgdGFtKTsKCXByaW50ZigiMCAtPiAlZFxuIiwgbm92b1swXSk7CglwcmludGYoIjEgLT4gJWRcbiIsIG5vdm9bMV0pOwoJcHJpbnRmKCIyIC0+ICVkXG4iLCBub3ZvWzJdKTsKCWZyZWUobm92byk7CglyZXR1cm4gMDsKfQo=