1 solutions
-
0
C :
#include<stdio.h> #include<stdlib.h> #include<string.h> typedef struct _node { char value; struct _node *next; } Node; typedef struct _stack { Node *head; } Stack; void push(Stack *stack, char tmp);//stack push char pop(Stack *stack);//stack pop int main(int argc, char *argv[]) { Stack stack; stack.head = NULL; char tmp, ago[1000]; scanf("%s", ago); int count = strlen(ago) , i; for(i = 0; i < count; i++){ push(&stack, ago[i]); } //judge for(i = 0; i < count; i++){ if(ago[i] != pop(&stack)){ printf("No\n"); // printf("No!\n"); return 0; } } // printf("Yes!\n"); printf("Yes\n"); return 0; } void push(Stack *stack, char tmp) { Node *p = (Node *)malloc(sizeof(Node)); p->value = tmp; p->next = NULL; if(stack->head) { p->next = stack->head; stack->head = p; } else stack->head = p; } char pop(Stack *stack){ if(stack->head) { Node *p = stack->head; stack->head = stack->head->next; return p->value; } else{ printf("The stack is empty!\n"); } }Pascal :
var a,s,d,f,g:longint; begin read(a); s:=a div 10000; d:=a div 1000 mod 10; f:=a div 10 mod 10; g:=a mod 10; if (s=g) and (d=f) then write('Yes') else write('No') end.
- 1
Information
- ID
- 17141
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By