Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Numerics;
- namespace _02.Convert_from_Base_10_to_Base_N
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split().ToArray();
- int Base = int.Parse(input[0]);
- BigInteger result = 0;
- StringBuilder numSB = new StringBuilder(input[1]);
- int power = 0; // сложих int вместо double
- int currentDigit = 0;
- BigInteger currRes = 0;
- int len = numSB.Length;
- for (int i = 0; i < len; i++)
- {
- currentDigit = int.Parse(numSB[numSB.Length - 1 - i].ToString());
- //power = Math.Pow(Base, i); вместо i исползвам pow++
- currRes = currentDigit * BigInteger.Pow(Base, power);
- result += currRes;
- power++;
- }
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement