當前位置:編程學習大全網 - 源碼下載 - 源代碼算術程序

源代碼算術程序

寫好了

不會計算小數,根據妳的問題。如果輸入小數,只取整數部分運算,結果不可能是負數?

#包含?

#包含?

#包含?

int?deal(int?op1,int?op2,char?op)?//操作?

{?

switch(op)?

{?

案子?+':op1?+=?op2?打破;?

案子?-':op1?-=?op2?打破;?

案子?*':op1?*=?op2?打破;?

案子?/':op1?/=?op2?打破;?

案子?'^':

{?

int?臨時工?=?op2?

for(int?我?=?1;?我?& lt?op2?-?1;?i++)?

op1?*=?溫度;?

打破;?

}?

}?

回歸?op 1;?

}?

夏爾?*替換(char?*來源,char?*sub,char?*代表)?//字符串替換?

{?

夏爾?*結果;?

夏爾?*pc1,*pc2,* pc3?

int?isource、isub、irep?

isub?=?strlen(sub);?

irep?=?strlen(代表);?

isource?=?strlen(來源);?

if(NULL?==?*sub)?

回歸?strdup(來源);?

結果?=?(char?*)malloc((?(irep?& gt?isub)?(float)strlen(來源)?/?isub*?irep+?1:isource?)?*?sizeof(char));?

pc1?=?結果;?

while(*來源?!=?NULL)?

{?

pc2?=?來源;?

pc3?=?sub?

while(*pc2?==?*pc3?& amp& amp?*pc3?!=?NULL?& amp& amp?*pc2?!=?NULL)?

pc2++,pc3++;?

if(NULL?==?*pc3)?

{?

pc3?=?rep?

而(*pc3?!=?NULL)?

*pc1++?=?* pc3++;?

pc2-;?

來源?=?pc2?

}?

不然呢?

*pc1++?=?*來源;?

source++;?

}?

*pc1?=?NULL?

回歸?結果;?

}?

int?main()?

{?

夏爾?s[1000],op1[100],op2[100],*p,*temp,* back?

scanf("%s ",& amps);?

臨時工?=?s;?

回來了?=?s;?

int?pos?=?-1;?

int?鰭,oper1,oper2,tmp,大小;?

夏爾?op;?

而(1)?

{?

尺寸?=?(int)strlen(temp);?

for(int?我?=?0;?我?& lt?尺寸;?i++,temp++)?

{?

如果(?*溫度?==?'(')?

{?

p?=?(temp?+?1);?

pos?=(我?+?1);?//找出最後壹個(?

}?

}?

int?k?=?0;?

如果(pos?!=?-1)?

{?

臨時工?=?背;?

tmp?=?pos?

while(*p?!=?')')?

{?

p++;?

tmp++;?

如果(?*p?==?'*'?||?*p?==?'/')?

{?

tmp-;?

for(;(temp[tmp]?& gt=?'0'?& amp& amp?temp[tmp]?=?'0'?& amp& amp?temp[pos]?=?'0'?& amp& amp?temp[pos]?=?'0'?& amp& amp?temp[pos]?=?'0'?& amp& amp?溫度[位置]

  • 上一篇:並發編程源代碼
  • 下一篇:仿照《巴金的故事》寫作文
  • copyright 2024編程學習大全網