Large number multiplication

Source: Internet
Author: User

#define_crt_secure_no_warnings#include<stdio.h>#include<stdlib.h>#include<string.h>//C Language Declaration variables need to be added stuct//there can be no function inside C language structure//C-language struct has no public, private, inheritedstructmystruct{intNUM1; intnum2; };structmystruct MyStruct1;///addition, subtraction///1234.567x12345.987///15k+ Division,//————————voidGetbigdata (Char*dataa,Char*Datab) {    intLengtha =strlen (DATAA); intLENGTHB =strlen (Datab); int*pres = (int*)malloc(sizeof(int) * (Lengtha +LENGTHB)); memset (pres,0,sizeof(int) * (Lengtha + LENGTHB));//Initialize//Tired Ride     for(inti =0; I < lengtha;i++)    {         for(intj =0; J < lengthb;j++) {pres[i+j+1]+= (Dataa[i]-'0') * (Datab[j]-'0'); }    }    //Rounding     for(inti = Lengtha + lengthb-1; i>=0; i--)    {        if(pres[i]>=Ten)//Rounding{pres[i-1] + = Pres[i]/Ten;//RoundingPres[i]%=Ten;//Remove single digit        }    }    inti =0;  while(pres[i]==0) {i++;//A position that is not exactly 0    }    Char*lastres =malloc(sizeof(Char) * (Lengtha +LENGTHB)); intJ;  for(j =0; J < Lengtha + LENGTHB; J + +, i++) {Lastres[j]= Pres[i] +'0'; } Lastres[j]=' /'; printf ("Last result =%s", lastres);}voidMain () {Charstr1[ -] = {0 }; Charstr2[ -] = {0 }; scanf ("%s%s", str1, str2); printf ("str1=%s,str2=%s", str1, str2);//Print ResultsGetbigdata (str1, str2); //strcpy (str1, "123123");System ("Pause");}

Large number multiplication

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.