Alx09

Untitled

Mar 9th, 2020
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5. char vect[125];
  6. unsigned i, ok, x, numberElem;
  7. for (i = 0; i < 125; i++)
  8. vect[i] = 0;
  9. printf("Introduceti numarul de elemente: "); scanf("%u", &numberElem);
  10.  
  11. for (i = 0; i < numberElem; i++) {
  12. printf("v[%u] = ", i + 1); scanf("%u", &x);
  13. vect[x / 8] |= 1 << x % 8;
  14. }
  15.  
  16. do {
  17. printf("Introduceti numarul cautat: "); scanf("%u", &x);
  18.  
  19. if (vect[x / 8] & (1 << x % 8))
  20. printf("Numarul se afla in vector\n\n");
  21. else
  22. printf("Numarul nu se afla in vector\n\n");
  23.  
  24. printf("Mai cautati alt numar? 0/1 : "); scanf("%u", &ok);
  25. } while (ok);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment