Patey

Untitled

Apr 12th, 2021
554
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3. #include<string.h>
  4.  
  5. int st[100],vf = -1;
  6. char a[1];
  7.  
  8. int empty()
  9. {
  10.     if (vf == -1)
  11.         return 1;
  12.     else
  13.         return 0;
  14. }
  15.  
  16. void push()
  17. {
  18.     vf++;
  19.     st[vf] = a[0];
  20. }
  21.  
  22. void ChangeFLag(int K,int *nr)
  23. {
  24.     *nr = *nr ^ (1 << K);
  25. }
  26.  
  27. void pop()
  28. {
  29.     vf--;
  30. }
  31.  
  32. int main()
  33. {
  34.     int i,nr;
  35.     int N,K;
  36.     int ok = 1;
  37.     printf("N=");
  38.     scanf("%d", &N);
  39.     getchar();
  40.     for(i=0;i<N;i++)
  41.     {
  42.         scanf("%c", a);
  43.         if (empty() == 1)
  44.             push();
  45.         else if (a[0] != st[vf])
  46.         {
  47.             pop();
  48.         }
  49.         else
  50.             push();
  51.         getchar();
  52.     }
  53.     nr = vf + 1;
  54.     printf("%d", nr);
  55.     printf("\nK=");
  56.     scanf("%d", &K);
  57.     for (i = 31; i >= 0; i--)
  58.         printf("%d", (nr >> i) & 1);
  59.     printf("\n");
  60.     ChangeFLag(K, &nr);
  61.     ChangeFLag(29 - K, &nr);
  62.     for (i = 31; i >= 0; i--)
  63.         printf("%d", (nr >> i) & 1);
  64.     printf("%d", nr);
  65. }
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.

×