Advertisement
DavidHandolescu

Untitled

Apr 7th, 2020
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include<string.h>
  5. int top = -1, stack[100];
  6. void Push(int x) {
  7.     stack[++top] = x;
  8. }
  9. int Pop() {
  10.     return stack[top--];
  11. }
  12. int Peek() {
  13.     return stack[top];
  14. }
  15. void problema()
  16. {
  17.     int i;
  18.     int j = 0;
  19.     char x[30] = "0xAABBCCDD";
  20.     char prg[30];
  21.     for(i=0;i<strlen(x);i++)
  22.     {
  23.         if (i == strlen(x)-1)
  24.         {
  25.             Push(x[i]);
  26.             prg[j++] = Pop();
  27.             Push(x[i - 1]);
  28.             prg[j++] = Pop();
  29.         }
  30.         if(i==strlen(x)-3)
  31.         {
  32.             Push(x[i]);
  33.             prg[j++] = Pop();
  34.             Push(x[i - 1]);
  35.             prg[j++] = Pop();
  36.         }
  37.         if (i == strlen(x) - 5)
  38.         {
  39.             Push(x[i]);
  40.             prg[j++] = Pop();
  41.             Push(x[i - 1]);
  42.             prg[j++] = Pop();
  43.         }if (i == strlen(x) - 7)
  44.         {
  45.             Push(x[i]);
  46.             prg[j++] = Pop();
  47.             Push(x[i - 1]);
  48.             prg[j++] = Pop();
  49.         }
  50.     }
  51.     for (i = 0; i < 9; i++) {
  52.         printf("%c", prg[i]);
  53.     }
  54. }
  55.  
  56. int main()
  57. {
  58.     problema();
  59.     system("pause");
  60.     return 0;
  61.    
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement