Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdlib.h>
- #include<stdio.h>
- #include<string.h>
- int st[100],vf = -1;
- char a[1];
- int empty()
- {
- if (vf == -1)
- return 1;
- else
- return 0;
- }
- void push()
- {
- vf++;
- st[vf] = a[0];
- }
- void pop()
- {
- vf--;
- }
- int main()
- {
- int i,nr=0;
- int ok = 1;
- while (1)
- {
- scanf("%c", a);
- /*do{
- ok = 1;
- scanf("%c", a);
- if ((strcmp(a, "F") != 0 && strcmp(a, "G") != 0) && strcmp(a, "S") != 0)
- {
- printf("Nu ii bine\n");
- ok = 0;
- }
- scanf("%c", a);
- } while (ok==0);*/
- if (strcmp(a,"S")==0)
- break;
- if (empty() == 1)
- push();
- else if (a[0] != st[vf])
- {
- pop();
- nr++;
- }
- else
- push();
- scanf("%c",a);
- }
- printf("\n\nContinutul stivei este:\n");
- for (i = 0; i <= vf; i++)
- {
- printf("%c\n", st[i]);
- }
- printf("\nNumarul de evaporari este: %d", nr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement