📄 1.txt
字号:
#include<iostream.h>
#include<string.h>
#define MAX_DIGITS 100
void Multiply(char*mulor,char*mulant,char*result);
void main()
{
char mulor[MAX_DIGITS+1];
char mulant[MAX_DIGITS+1];
char result[2*MAX_DIGITS+1];
cout<<"input one number ";
cin>>mulor;
cout<<"input another number ";
cin>>mulant;
char *ptor = mulor;
char *ptant = mulant;
Multiply(mulor,mulant,result);
cout<<mulor<<" * "<<mulant<<" = "<<result<<endl;
}
void Multiply(char*mulor,char*mulant,char*result)
{
char one[MAX_DIGITS];
char two[MAX_DIGITS];
char rel[2*MAX_DIGITS];
int pro[2*MAX_DIGITS];
int row = strlen(mulant);//?ˊ?t col = strlen(mulor);//???ˊ? int i,j;
strcpy(one,mulor);
strcpy(two,mulant);
for (i=0;i<2*MAX_DIGITS;i++)
pro[i]=0;
for(i = row-1; i >=0; i--)
for(j = col-1 ; j >= 0; j--)
{
int product = (one[j]-'0')*(two[i]-'0');
pro[i+j+0] += product/10 ;
pro[i+j+1] += product%10 ;
}
for(i = row+col-1; i>0;i--)
{
if(pro[i]>=10)
{
pro[i-1] +=pro[i]/10;
pro[i] =pro[i]%10;
}
}
int pos =0;
for(i = 0;i<row +col;i++)
if (pro[i]!= 0)
{
pos = i;
break;
}
for(i = 0,j = pos;i<row +col;i++,j++)
rel[i] = pro[j]+'0';
rel[row+col-1]='\0';
strcpy(result,rel);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -