#include
#include
void main()
{
float a[10],sum=0;
char b[10];
int i,j,k;
clrscr();
for(i=0;i<10;)
{
if(i%2==0)
scanf("%f",&a[i]);
else
{
b[i]=getchar();
if(b[i]=='=')
{
k=i;
break;
}
}
i=i+1;
}
for(j=0;j<5;j++)
{
if(j%2==0)
printf("%f",a[j]);
else
putchar(b[j]);
}
printf("value =%d",k);
for(j=0;j
{
if(j%2==1)
{
if(b[j]=='/')
a[j-1]=a[j-1]/a[j+1];
}
}
for(j=0;j
{
if(j%2==1)
{
if(b[j]=='*')
a[j-1]=a[j-1]*a[j+1];
}
}
for(j=0;j
{
if(j%2==1)
{
if(b[j]=='+')
sum=sum+a[j-1];
if(b[j]=='-')
sum=sum-a[j-1];
}
}
printf("Sum=%f",sum);
getch();
}
0 comments:
Post a Comment