#include <stdio.h>
#include <stdlib.h>
int main( void ) {
int i;
printf ( "\n Digite a quantidade de numeros que serao digitados: " ) ; int * p
= malloc ( i
* sizeof ( int ) ) ; if ( p == NULL) {
printf ( "\n ERRO.MEMORIA INSUFICIENTE" ) ; }
for ( int k = 0 ; k < i; k++ ) {
printf ( "\n Digite o % do valor do vetor: " , k
+ 1 ) ; }
printf ( "\n \n ========== VETOR PREENCHIDO ==========\n " ) ; for ( int k
= 0 ; k
< i
; k
++ ) printf ( "%d\t " , p
[ k
] ) ; printf ( "\n \n Seu vetor possui %d elementos." , i
) ; printf ( "\n Digite um valor positivo para aumentar ao vetor." ) ; printf ( "\n Digite um valor negativo para diminuir do vetor.\n \n " ) ; int n;
if ( ! ( i + n) ) {
printf ( "\n Seu vetor possui 0 elementos.\n \n " ) ; } else if ( ( i + n) < 0 ) {
printf ( "\n Seu vetor possui quantidade negativa de elemento.\n \n IMPOSSIVEL ALOCAR MEMORIA.\n \n " ) ; }
p
= realloc ( p
, ( i
+ n
) * sizeof ( int ) ) ; if ( p== NULL) {
printf ( "\n ERRO DE RE-ALOCACAO.MEMORIA INSUFICIENTE" ) ; }
for ( int k = i; k < ( n + i) ; k++ ) {
printf ( "\n Digite o % do valor do vetor: " , k
+ 1 ) ; }
printf ( "\n \n ========== VETOR PREENCHIDO REALOCADO ==========\n " ) ; for ( int k = 0 ; k < ( n+ i) ; k++ ) {
}
free ( p
) ; //na prática não é necessário aqui porque o programa vai encerrar, mas pra fins de aprendizado ok }
//https://pt.stackoverflow.com/q/215422/101
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBtYWluKHZvaWQpIHsKICAgIGludCBpOwogICAgcHJpbnRmKCJcbkRpZ2l0ZSBhIHF1YW50aWRhZGUgZGUgbnVtZXJvcyBxdWUgc2VyYW8gZGlnaXRhZG9zOiAiKTsKICAgIHNjYW5mICgiJWQiLCAmaSk7CiAgICBpbnQgKnAgPSBtYWxsb2Mo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