求高手帮忙,看看哪里错了
学C不到一个月第一次编程序,各位高手帮忙看一下吧,先谢过啦~~这是个求混合运算的计算器的程序~~#include <stdio.h>
void main()
{
int a[20],sum=0;
char b[20],c[20],d[20];
int i;
printf("输入您的算式:");
scanf("%s",&d[]);
for(i=0,d[i]!='\n',i++)
switch(d[i])
{
case 0: a[i]=d[i]; break;
case 1: a[i]=d[i]; break;
case 2: a[i]=d[i]; break;
case 3: a[i]=d[i]; break;
case 4: a[i]=d[i]; break;
case 5: a[i]=d[i]; break;
case 6: a[i]=d[i]; break;
case 7: a[i]=d[i]; break;
case 8: a[i]=d[i]; break;
case 9: a[i]=d[i]; break;
case *: b[i]=d[i]; break;
case /: b[i]=d[i]; break;
case +: c[i]=d[i]; break;
case -: c[i]=d[i]; break;
}
for(i=0,b[i]!='\n',i++)
{ switch(b[i])
{
case *: a[i+1]=a[i-1]*a[i+1], a[i-1]=a[i+1] ; break;
case /: a[i+1]=a[i-1]/a[i+1], a[i-1]=a[i+1] ; break;
case 0: ; break;
}
}
for(i=0,c[i]!='\n',i++)
{ switch(b[i])
{
case +: a[i+1]=a[i-1]+a[i+1], sum=a[i+1] ; break;
case -: a[i+1]=a[i-1]-a[i+1], sum=a[i+1] ; break;
case 0: ; break;
}
}
printf("运算结果是:%f",sum);
}
[ 本帖最后由 scottwind 于 2011-11-23 01:52 编辑 ]