Ejercicios de vectores y funciones con c++

Páginas: 8 (1959 palabras) Publicado: 20 de julio de 2010
GENERAR UN VECTOR, LUGO GENERAR OTRO PARA LOS NÚMEROS PARES Y OTRO PARA LOS IMPARES.
BIBLIOTECA….
main(){
int ne,vec1[100],vec2[100],vec3[100],i,j=0,l=0,k;
printf("digite numero de elementos\n");
scanf("%d",&ne);
for (i=1;i<=ne ;i++){
vec1[i]=100*rand()/32767;
}
for (i=1;i<=ne;i++){
if(vec1[i]%2==0){
j++;
vec2[j]=vec1[i]; }
else{
l++;
vec3[l]=vec1[i]; }
}
printf("\n VECTOR ORIGINAL " );
for(k=1;k<=ne;k++){
printf("%5d",vec1[k]);
}
printf("\n VECTOR PARES " );
for(k=1;k<=j;k++){printf("%5d",vec2[k]);
}
printf("\n VECTOR IMPARES " );
for(k=1;k<=l;k++){
printf("%5d",vec3[k]);
}
printf("\n enter para terminar\n");
getch();
}

GENERAR UN VECTOR CUYOS NÚMEROS ESTEN COMPRENDIDOS ENTRE DOS LÍMITES.BIBLIOTECA…
main () {
int i, temp,x, y, vec [500],n;
printf("digite limite inferior ");
scanf("%d",&x);
printf("digite limite superior ");
scanf("%d",&y);
printf("digite número de elementos ");
scanf("%d",&n);
if (y<x){
temp=y;y=x;
x=temp;
}
for (i=1; i<=n; i++){
vec[i]=y*rand()/32767;
printf("%5d", vec[i]);
if (vec[i]<x){
i--;}
}
printf ("vector generado\n ");
for (i=1; i<=n;i++)
printf("%5d", vec[i]);
printf("\n intro para terminar");
getch();
}
GENERAR UN VECTOR, LUEGO DECIRCUAL NÚMERO INCLUIR, LUEGO DECIR DESPUES DE CUAL NÚMERO INCLUIR, Y POR ÚLTIMO MOSTRAR EL NUEVO VECTOR CON EL NÚMERO QUE SE MENCIONO.
BIBLIOTECA…
main () {
int l,j,vec [500],n,in, po,temp;
printf("digite número de elementos ");
scanf("%d",&n);
for (l=1;l<=n; l++){vec[l]=500*rand()/32767;
printf("%4d", vec[l]);
}
printf("\ndigite número a incluir ");
scanf("%d",&in);
printf("\ndigite después de cuál incluir ");
scanf("%d",&po);
for (l=1;l<=n; l++){if (vec[l]==po){
temp=vec[l];
vec[l]=in;
vec[l+1]=temp;
vec[]++;
}
}printf ("VECTOR GENERADO ");
for (l=1;l<=n+1; l++){
printf("%4d", vec[l]);
}
printf("\n intro para terminar");
getch();
}

GENERAR UN VECTOR CON NÚMEROS ALEATORIOS, Y DECIR CUÁL ES EL MAYOR Y CUÁL EL MENOR.
BIBLIOTECA…...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Ejercicios Con Vectores C++
  • Ejercicio Vectores Lenguaje C
  • Ejercicios de funciones de programación en C
  • ejercicios de vectores en c
  • funciones y vectores (c++)
  • VECTORES EJERCICIOS
  • Ejercicios de Vectores
  • ejercicios de vectores

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS