Em um vetor de 16 posições deve-se trocar os 8 primeiros valores pelos 8 últimos e
vice-e-versa...
Eu escrevi isso:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void) {
int vetorPrincipal[16]={0};
int vetorA[8]={0};
int vetorB[8]={0};
int i = 0;
printf("Vetor : ");
for(i=0; i<16; ++i){
printf("%d ",rand() % 100);
if (i < 8){
vetorB=vetorPrincipal;
} else if ((i >= 8) && (i < 16)) {
vetorA=vetorPrincipal;
}
}
printf("\n");
printf("Novo vetor : ");
for(i=0; i<16; ++i){
if (i < 8){
vetorPrincipal=vetorA;
} else if ((i >=8) && (i < 16)) {
vetorPrincipal=vetorB;
}
printf("%d ",vetorPrincipal);
}
printf("\n");
system("PAUSE");
return 0;
}
O que estou fazendo de errado ?