fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include<stdlib.h>
  4. struct node
  5. {
  6. char ch;
  7. struct node * next;
  8. };
  9. int listSize=0;
  10. struct node* stackHead=NULL;
  11. struct node* queueHead=NULL;
  12. struct node* queuetail=NULL;
  13. //----------------------------------
  14. void push(char c)
  15. {
  16. struct node *new=(struct node *)malloc(sizeof(struct node));
  17. //if(new==NULL){printf("NOT\n");}
  18. new->ch=c;
  19. new->next=stackHead;
  20. stackHead=new;
  21. listSize++;
  22. }
  23. //------------------------------
  24. char pop()
  25. {
  26. struct node* current=stackHead;
  27. char z;
  28. //if(stackHead==NULL){printf("error");}
  29. stackHead=current->next;
  30. z=current->ch;
  31. free(current);
  32. listSize--;
  33. return z;
  34. }
  35.  
  36. //------------------------------
  37. void enqueue(char c)
  38. {
  39. struct node* new;
  40. new=(struct node *)malloc(sizeof(struct node));
  41. new->next=NULL;
  42. //if(new==NULL){printf("NOT\n");}
  43. new->ch=c;
  44. new->next=NULL;
  45. if((queueHead==NULL)&&(queuetail==NULL))
  46. {
  47. queueHead=new;
  48. queuetail=new;
  49. listSize++;
  50. }
  51. else
  52. {
  53. queuetail->next=new;
  54. queuetail=new;
  55. listSize++;
  56. }
  57. }
  58. //-----------------------------------------------------
  59. char dequeue()
  60. {
  61. if((queueHead==NULL)&&(queuetail==NULL)){ printf("empty\n");
  62. return 0;}
  63. else
  64. {
  65. struct node* tmp1=queueHead;
  66. queueHead=queueHead->next;
  67. char w;
  68. w=tmp1->ch;
  69. free(tmp1);
  70. listSize--;
  71. return w;
  72. }
  73. }
  74. //----------------------------------
  75. int isEmpty()
  76. {
  77. int z;
  78. if(stackHead==NULL)
  79. {
  80. z=1;
  81. }
  82. else
  83. {
  84. z=0;
  85. }
  86. return z;
  87. }
  88. //------------------------------------
  89.  
  90. int main()
  91. {
  92. char stackChar;
  93. char queueChar;
  94. char x;
  95. int i,length;
  96. //int ispalindrome;
  97. scanf("%d",&length);
  98. int y=1;
  99. for(i=0;i<length;i++)
  100. {
  101. while(y==scanf("%c",&x))
  102. {
  103. if(x !=' '){
  104. push(x);
  105. enqueue(x);
  106. }
  107.  
  108. }
  109.  
  110. while (!isEmpty(&stackHead))
  111. {
  112. stackChar=pop();
  113. queueChar=dequeue();
  114. printf("%c",stackChar);
  115. /*if (stackChar==queueChar)
  116. {
  117. ispalindrome= 1;
  118. printf("%c %c\n",stackChar,queueChar);
  119. }
  120. else
  121. {
  122. ispalindrome = 0;
  123. printf("%c %c\n",stackChar,queueChar);
  124. break;
  125. }*/
  126. }
  127. *stackHead=NULL;
  128. *queueHead=NULL;
  129. *queuetail=NULL;
  130. printf("\n...\n");
  131. //printf("%d\n",ispalindrome);
  132. }
  133. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:127: error: incompatible types in assignment
prog.c:128: error: incompatible types in assignment
prog.c:129: error: incompatible types in assignment
stdout
Standard output is empty