Paisen

posicion

Sep 27th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. /*5) Buscar un elemento dentro de un arreglo
  2. que nosotros le pedimos por teclado.Indicar la
  3. posición donde se encuentra. Si hay más de uno,
  4. indicar igualmente laposición.*/
  5.  
  6. #include<stdio.h>
  7. #include<stdlib.h>
  8.  
  9. int  i,x,z;
  10. char b,c,B[50];
  11.  
  12. int main (){
  13.    
  14.     printf("Introduza los datos de su arreglo:\n");
  15.     scanf("%c",&b);
  16.  
  17.     while(i<50 && b != '\n'){
  18.     B[i]=b;
  19.     i++;
  20.     scanf("%c",&b);
  21.     }
  22.    
  23.     printf("\nQue caracter o numero quiere buscar en su arreglo?\n");
  24.     scanf("%c",&c);
  25.    
  26.     printf("EL caracter se encuentra en la o las posicion/es:");
  27.     for(z=0; z<=i; z++){
  28.     if( B[z]==c){
  29.     x=z;
  30.     printf("  %d  ",x+1);  
  31.     }
  32.    }
  33.    
  34.     printf("\n\n");
  35.     system("pause");
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment