早教吧 育儿知识 作业答案 考试题库 百科 知识分享

用C语言编译一个简单计算器的程序,要求其中有括号和幂函数请各位高手帮忙编译一个简单计算器的程序,可以运行加减乘除,括号和幂函数谢啦

题目详情
用C语言编译一个简单计算器的程序,要求其中有括号和幂函数请各位高手帮忙编译一个简单计算器的程序,可以运行加减乘除,括号和幂函数 谢啦
▼优质解答
答案和解析
写好了 不能算小数,根据你的题意来的,如果输入小数,则只取整数部分运算,结果不能为负数 #include #include #include intdeal(intop1,intop2,charop)//运算 { switch(op) { case'+':op1+=op2;break; case'-':op1-=op2;break; case'*':op1*=op2;break; case'/':op1/=op2;break; case'^': { inttemp=op2; for(inti=1;iisub)?(float)strlen(source)/isub*irep+1:isource)*sizeof(char)); pc1=result; while(*source!=NULL) { pc2=source; pc3=sub; while(*pc2==*pc3&&*pc3!=NULL&&*pc2!=NULL) pc2++,pc3++; if(NULL==*pc3) { pc3=rep; while(*pc3!=NULL) *pc1++=*pc3++; pc2--; source=pc2; } else *pc1++=*source; source++; } *pc1=NULL; returnresult; } intmain() { chars[1000],op1[100],op2[100],*p,*temp,*back; scanf("%s",&s); temp=s; back=s; intpos=-1; intfin,oper1,oper2,tmp,size; charop; while(1) { size=(int)strlen(temp); for(inti=0;i='0'&&temp[tmp]='0'&&temp[pos]='0'&&temp[pos]='0'&&temp[pos]='0'&&temp[pos]