#include<stdio.h>
#include<stdlib.h>
int main()
{
int i;
int j=-1;
char tempTop[10]={'A','B','C','D','E','F','G','H','I','J'};
while(i!=143){
printf("\n\n(143 to EXIT)\nPress 0 to PUSH or 1 to POP: ");
scanf("%d",&i);
system("cls");
if(i==0){
if(j<9){
j++;
for(int x=j;x>=0;x--){
if(x<j)
printf("%c\n",tempTop[x]);
else
printf("%c <---top\n",tempTop[x]);
}
}else{
for(int x=j;x>=0;x--){
if(x<j)
printf("%c\n",tempTop[x]);
else{
printf("Stack already Full!\n");
printf("%c <---top\n",tempTop[x]);
}
}
}
}
else if(i==1){
if(j>-1){
j--;
for(int x=j;x>=0;x--){
if(x<j)
printf("%c\n", tempTop[x]);
else
printf("%c\ <---top\n",tempTop[x]);
}
}else{
printf("PUSH MO YAN\n");
}
}else
for(int x=j;x>=0;x--){
if(x<j)
printf("%c\n",tempTop[x]);
else{
printf("Oops: Press 0 or 1 only!\n");
printf("%c\n",tempTop[x]);
}
}
}
system("cls");
return 0;
}
#include<stdlib.h>
int main()
{
int i;
int j=-1;
char tempTop[10]={'A','B','C','D','E','F','G','H','I','J'};
while(i!=143){
printf("\n\n(143 to EXIT)\nPress 0 to PUSH or 1 to POP: ");
scanf("%d",&i);
system("cls");
if(i==0){
if(j<9){
j++;
for(int x=j;x>=0;x--){
if(x<j)
printf("%c\n",tempTop[x]);
else
printf("%c <---top\n",tempTop[x]);
}
}else{
for(int x=j;x>=0;x--){
if(x<j)
printf("%c\n",tempTop[x]);
else{
printf("Stack already Full!\n");
printf("%c <---top\n",tempTop[x]);
}
}
}
}
else if(i==1){
if(j>-1){
j--;
for(int x=j;x>=0;x--){
if(x<j)
printf("%c\n", tempTop[x]);
else
printf("%c\ <---top\n",tempTop[x]);
}
}else{
printf("PUSH MO YAN\n");
}
}else
for(int x=j;x>=0;x--){
if(x<j)
printf("%c\n",tempTop[x]);
else{
printf("Oops: Press 0 or 1 only!\n");
printf("%c\n",tempTop[x]);
}
}
}
system("cls");
return 0;
}
OUTPUT
No comments:
Post a Comment