Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- char vect[125];
- unsigned i, ok, x, numberElem;
- for (i = 0; i < 125; i++)
- vect[i] = 0;
- printf("Introduceti numarul de elemente: "); scanf("%u", &numberElem);
- for (i = 0; i < numberElem; i++) {
- printf("v[%u] = ", i + 1); scanf("%u", &x);
- vect[x / 8] |= 1 << x % 8;
- }
- do {
- printf("Introduceti numarul cautat: "); scanf("%u", &x);
- if (vect[x / 8] & (1 << x % 8))
- printf("Numarul se afla in vector\n\n");
- else
- printf("Numarul nu se afla in vector\n\n");
- printf("Mai cautati alt numar? 0/1 : "); scanf("%u", &ok);
- } while (ok);
- }
Advertisement
Add Comment
Please, Sign In to add comment