Advertisement
Mazamin

01_10_1.3

Oct 2nd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. /*
  2.  * File:   main.c
  3.  * Author: Gerardo Cicalese
  4.  *
  5.  * Created on 16 settembre 2019, 15.48
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. #define TRUE 1
  12. #define FALSE 0
  13.  
  14. int search_vex(int * vex, int n, int a){
  15.     if(n<2)
  16.         if( *vex == a && n == 1 )
  17.             return TRUE;
  18.         else
  19.             return FALSE;
  20.     else
  21.         if( (*vex) == a )
  22.             return TRUE;
  23.         else
  24.             return  search_vex(vex+1, n-1, a);
  25. }
  26.  
  27. int main(void){
  28.     int elem, vex[]={63, 15, 42, 63, 92, 34, 77, 23, 78, 37, 26, 7, 79, 85, 82, 19, 89, 10, 64};
  29.     size_t len=sizeof(vex)/sizeof(vex[0]);
  30.     scanf("%d", &elem);
  31.     printf("%d is %s\n", elem, (TRUE==search_vex(vex, len, elem))?("found"):("not found") );
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement