Skip to content

Instantly share code, notes, and snippets.

@gonzalowtf
Created September 4, 2012 13:41
Show Gist options
  • Save gonzalowtf/3621255 to your computer and use it in GitHub Desktop.
Save gonzalowtf/3621255 to your computer and use it in GitHub Desktop.
// programa 1, arreglos, mostrar cuantas veces se repite en el arreglo un numero ingresado
#include<stdio.h>
void cargarvector(int, int[]);
int main(int argc , char*, int argv[])
{
int h,x,i, cont;
i=1;
cont =0;
printf("ingrese el orden del vector");
scanf("%d", &h);
printf("ingrese el valor a buscar en el arreglo: ");
scanf("%d", &x);
int v[h];
cargarvector(h, v);
for(i=1; i<=h;i++)
{
if(x==v[i]) cont++;
}
printf(" la cantidad de veces que se repite en el arreglo son: %d",cont);
fgetc(stdin);
fgetc(stdin);
return 0;
}
void cargarvector(int h, int v[])
{
int i;
i=1;
for(i=1; i<=h; i++)
{
printf("ingrese un valor para el vector: ");
scanf("%d", &v[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment