4 programas vectores y arreglos
PROGRAMA 1
PROGRAMA 1
#include
"stdafx.h"
#include
<stdio.h>
#include
<conio.h>
void
llenar (int V[],int
d)
{
for (int i=1; i<=d;i++)
{
printf("inserte
pos.[%d]:",i);
scanf("%d",&V[i]);
}
}
void
mostrar(int V[],int
d)
{
for(int i=1;i<=d;i++)
{
printf("[%d]", V[i]);
}
}
void
invierte (int V[],int
d)
{
int
aux1;
int
fin1=d/2;
for(int i=1;i<=(d/2)/2;i++)
{
aux1=V[i];
V[i]=V[fin1];
V[fin1]=aux1;
fin1--;
}
fin1=d;
for(int j=(d/2)+1;j <=(d/2)+1;j++)
{
aux1=V [j];
V[j]=V[fin1];
V
[fin1]=aux1;
fin1--;
}
}
int
main ()
{
int
V[20];
int
d;
printf("inserte
dimen.del vector:");
scanf("%d",&d);
llenar(V,d);
printf("\n VECTOR
ORIGINAL: \n");
mostrar(V,d);
printf("\n \n
VECTOR LUEGO DE LA VERSION: \n");
invierte(V,d);
mostrar(V,d);
getch();
}

No hay comentarios:
Publicar un comentario