/***********************************************************************
求两个字符串的乘积,结果存到字符串中,例如字符串一中存的“657891”,
字符串二中存的“521”,分别将字符串中的字符转换成整型数字,进行计算后,
再转换成字符类型存储起来
************************************************************************/
#include<cstdio>
#include <cstdlib>
#include<cstring>
/*--------------------------库函数实现--------------------------------*/
void Mul(char *input1,int n1,char *input2, int n2,char *output)
{
char *p1=input1;
char *p2=input2;
int res1,res2,res;
char tmp[50];
int m=0,i;
if(p1 == NULL || p2 == NULL)
return;
res1=atoi(p1);
res2 = atoi(p2);
res = res1*res2;
itoa(res,tmp,10);
strcpy(output,tmp);
}
/*--------------------------------------------------------------------*/
void mul(char *input1,int n1,char *input2, int n2,char *output)
{
char *p1=input1;
char *p2=input2;
int res1,res2,res;
char tmp[50];
int m=0,i;
if(p1 == NULL || p2 == NUL
华为:将两个数从字符串转为数,将这两个数做乘积后再转化为字符串保存起来
最新推荐文章于 2025-07-04 09:00:00 发布