Patey

Untitled

Apr 12th, 2021
523
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3.  
  4.  
  5. int main()
  6. {
  7.     int N, Q, a[100],i,x,j,k,ok;
  8.     printf("N=");
  9.     scanf("%d", &N);
  10.     for (i = 0; i < N; i++)
  11.     {
  12.         scanf("%d", &a[i]);
  13.     }
  14.     printf("Q=");
  15.     scanf("%d", &Q);
  16.  
  17.     for (i = 0; i < Q; i++)
  18.     {
  19.         ok = 0;
  20.         printf("X= ");
  21.         scanf("%d", &x);
  22.         for (j = 0; j < N; j++)
  23.         {
  24.             if (a[j] == x)
  25.             {
  26.                 printf(":)\t");
  27.                 for (k = 2; k >= 0; k--)
  28.                     printf("%d", (x >> k) & 1);
  29.                 printf("\n\n");
  30.                 ok = 1;
  31.                 break;
  32.             }
  33.             else if (a[j] > x)
  34.                 break;
  35.         }
  36.         if (ok == 0)
  37.             printf(":(\n\n");
  38.     }
  39. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×