pc_math
یک شنبه 20 آبان 1386, 22:01 عصر
برنامه ای بنویسید که رشته ای را از کاربر بگیرد و آن را بصورت معکوس چاپ کند(با استفاده از پشته ها):
#include <iostream.h>
#include <conio.h>
#include <math.h>
#define max 100;
int s[max];
int top=0;
int i;
void push(char s[], int i);
int pop();
int main(){
char ch;
cout<<"Enter string:";
cin>>i;
while(ch!=13)
push(s[max],i);
cout<<pop;
getch();
return 0;
}
//
void push(char s[], int i)
{
if(top >= max){
cout<<"\n stack is full.";
getch();
return;
}
s[top]=i;
top++;
}
//
int pop()
{
top--;
if(top < 0){
cout<<" \n stack is empty";
return HUGE_VAL;
}
return s[top];
}
(لطفا نخندید ضعیف ترین دانشجو تو کلاسمونم)
#include <iostream.h>
#include <conio.h>
#include <math.h>
#define max 100;
int s[max];
int top=0;
int i;
void push(char s[], int i);
int pop();
int main(){
char ch;
cout<<"Enter string:";
cin>>i;
while(ch!=13)
push(s[max],i);
cout<<pop;
getch();
return 0;
}
//
void push(char s[], int i)
{
if(top >= max){
cout<<"\n stack is full.";
getch();
return;
}
s[top]=i;
top++;
}
//
int pop()
{
top--;
if(top < 0){
cout<<" \n stack is empty";
return HUGE_VAL;
}
return s[top];
}
(لطفا نخندید ضعیف ترین دانشجو تو کلاسمونم)