#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
#define MAX 100
char news[MAX]={"4526"};
void mul(int n)
{
int carry=0;int i;
//前几位
for(i=strlen(news)-1;i>0;i--)
{
int res=(news[i]-'0')*n+carry;
//如果有进位
if(res/10>0)
{
int zhen=res/10;
int yush=res%10;
news[i]=yush+'0';
carry=zhen;
}
else
{
carry=0;
int yush=res%10;
news[i]=yush+'0';
}
}
//最后一位
int res=(news[0]-'0')*n+carry;
if(res/10>0)
{
int zhen=res/10;
int yush=res%10;
//存储yush
news[0]=yush+'0';
//存储zhen
int i;
for(i=strlen(news)-1;i>=0;i--)
{
news[i+1]=news[i];
}
news[0]=zhen+'0';
}
else
{
int yush=res%10;
news[0]=yush+'0';
}
}
int main()
{
mul(7);
return 0;
}
/*
1 整数乘法跟字符串不相同,字符串为456,就是从4开始成,但是如果是int从6开始乘
而且存储的时候也是从6开始存储的。
*/
大数乘法(乘数是10以内)(被乘数是sting)
最新推荐文章于 2021-04-07 22:59:31 发布