+ 28
Multiplication of two large number in c# or c++
please help me to write a this program Multiplication of two large number.
6 ответов
+ 8
Great exercise.
You know how to multiply two large numbers by hand, ie long multiplication? That’s just an algorithm. Turn it into code. Use arrays to hold the digits. If you want to multiply 100 digit numbers together, use arrays that hold a 100 numbers for the two numbers and 200 digits for the product. Or see how big the numbers are, then pick array sizes of a suitable size.
You might want to start with adding two 100 digit numbers together, because the standard algorithm for long multiplication includes adding numbers together, so you have to do it anyway and as it is so simple it is a good place to start.
For Detailed Resources: Google
Happy Coding </>
+ 21
i can write sum of two large number
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication170
{
class Program
{
static void Main(string[] args)
{
string a = Console.ReadLine();
string s = Console.ReadLine();
if (a.Length != s.Length)
{
int NIM = Math.Abs(a.Length - s.Length);
string A = "";
for (int i = 0; i < NIM; i++)
{
A += "0";
}
if (a.Length > s.Length)
{
s = A + s;
}
else
{
a = A + a;
}
}
int GIF = 0;
string sum = "";
for (int i = a.Length - 1; i >= 0; i--)
{
int r = Convert.ToInt32(a[i].ToString()) + Convert.ToInt32(s[i].ToString()) + GIF;
if (r > 9)
{
GIF = 1;
r -= 10;
}
else
{
GIF = 0;
}
sum = r.ToString() + sum;
}
if (GIF != 0)
{
sum = GIF.ToString() + sum;
}
Console.WriteLine(sum);
Console.ReadKey();
}
}
}
+ 17
Do u know what's the answer
+ 16
I fixed it
+ 16
Its better than now
+ 9
Tnx a lot raj