#include"stdio.h"
#include"string.h"
#include"math.h"
#include"stdlib.h"
void convlute(char s1[20],char s2[20])
{
int i,p=0,t=0;
char s3[20];
for(i=0;i<20;i++)
{
if(s1[i]!='+'&&s1[i]!='-'&&s1[i]!='*'&&s1[i]!='/'&&s1[i]!='('&&s1[i]!=')')
{
s2[p]=s1[i];
p++;
}
else if(s1[i]='(')
{
t++;
}
else if(s1[i]=='+'||s1[i]=='-')
{
if(s3[t]=='*'||s3[t]=='/')
{
s2[p]=s3[t];
s3[t]=s1[i];
t++;
p++;
}
else
{
s3[t]=s1[i];
t++;
}
}
else if(s1[i]=='*'||s1[i]=='/')
{
s2[p]=s1[i];
p++;
}
else if(s1[i]==')')
{
do
{
s2[p++]=s3[t--];
}
while(s3[t]!='(');
}
}
}
void main()
{
char x[20],y[20];
int i;
for(i=0;i<20;i++)
scanf("%c",&x[i]);
for(i=0;i<20;i++)
y[i]=0;
convlute(x[20],y[20]);
printf("%s",y);
}
ahmed hefnawy 0 Newbie Poster
Recommended Answers
Jump to Post"It doesn't work" isn't going to cut it. Give us some specifics.
Also, use code tags
Jump to PostThe info helps, but that's not what I mean by specifics... What are the errors?
All 8 Replies
Fbody 682 Posting Maven Featured Poster
ahmed hefnawy 0 Newbie Poster
ahmed hefnawy 0 Newbie Poster
Fbody 682 Posting Maven Featured Poster
ahmed hefnawy 0 Newbie Poster
abhimanipal 91 Master Poster
ahmed hefnawy 0 Newbie Poster
abhimanipal 91 Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.