輸入 string a, string b; 計算string c=a*b; 返回 c;
1, 紀錄小數點在a,b中的位置l1,l2, 則需要小數點後移動位置數為l=length(a)+length(b)-l1-l2-2;
2, 去掉a,b中的小數點,(a,b小數點後移,使a,b變為整數)
3, 計算c=a*b; (同整數的大數相乘演算法)
4, 輸出c,(注意在輸出倒數第l個數時,輸出乙個小數點。若是輸出的數少於l個,就補0)
du51(鬱鬱思揚)的答案:
變為整數求就行了.輸入的時候記一下,小數點位置..輸出再做點文章就行了.
下面的是大整數的運算.
#include
using namespace std;
#define max 10000
struct node;
void output(node *head)
void mul(char *a,char *b,int pos)
if(*ap==0)temp1=temp;
else
p1->data=temp1%10;
//留當前位
temp=temp1/10;
//進製以int的形式留下.
p1=p;p=p->next;
//被乘數到下一位
} ap=a;bp++;q=q->next;
//q進下一位
} p=head;
output(p);
//顯示
cout<
while(head)
//釋放空間 }
int main()
上面大整數已經寫了.你加幾個東西就行了.
#include
using namespace std;
#define max 10000
struct node;
void output(node *head,int pos)
void mul(char *a,char *b,int pos)
if(*ap==0)temp1=temp;
else
p1->data=temp1%10;
//留當前位
temp=temp1/10;
//進製以int的形式留下.
p1=p;p=p->next;
//被乘數到下一位
} ap=a;bp++;q=q->next;
//q進下一位
} p=head;
output(p,pos);
//顯示
cout<
while(head)
//釋放空間 }
int main()
while(*p);
} if(p=strchr(test2,'.'))
while(*p);
} mul(strrev(test1),strrev(test2),pos);
system("pause");
return 0;}
**至微博
**至微博
ASP中保留小數點後兩位數的方法
這篇文章主要介紹了asp中保留小數點後兩位數的方法,使用formatnumber函式實現,需要的朋友可以參考下 近來用asp程式處理一些資料表單,遇到數字格式化的問題,如資料保留幾位小數等問題,經過研究,可以使用asp的內建函式formatnumber來實現,下面就具體說說formatnumber函...
ASP中保留小數點後兩位數的方法
這篇文章主要介紹了asp中保留小數點後兩位數的方法,使用formatnumber函式實現,需要的朋友可以參考下 近來用asp程式處理一些資料表單,遇到數字格式化的問題,如資料保留幾位小數等問題,經過研究,可以使用asp的內建函式formatnumber來實現,下面就具體說說formatnumber函...
ASP中保留小數點後兩位數的方法
這篇文章主要介紹了asp中保留小數點後兩位數的方法,使用formatnumber函式實現,需要的朋友可以參考下 近來用asp程式處理一些資料表單,遇到數字格效果可以看下具體51搜尋展示結合xunsearch全文檢索技術,可以達到毫秒級的資料搜尋式化的問題,如資料保留幾位小數等問題,經過研究,可以使用...