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;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numeralSystem = int.Parse(Console.ReadLine());
- string input = Console.ReadLine();
- int totalValue = 0;
- string convertedValue = "";
- for (int i = 0; i < input.Length; i++)
- {
- char kondio = input[i];
- if (kondio >= 'A' && kondio <= 'Z')
- {
- totalValue += kondio - 64;
- }
- else if (kondio >= 'a' && kondio <= 'z')
- {
- totalValue += kondio - 96;
- }
- else
- {
- totalValue += kondio;
- }
- }
- ////////////////////////////
- do
- {
- convertedValue = (totalValue % numeralSystem) + convertedValue;
- totalValue /= numeralSystem;
- }
- while (totalValue != 0);// kogato celochislenata stoinost stane 0 prekusvame // ne e ravno na 0 zatova e !=0 da e razlichno ot 0 da kajem 4e moje da smqtame i otricatelni chisla
- Console.WriteLine(numeralSystem.ToString() + input.Length.ToString() + convertedValue);
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numeralSystem = int.Parse(Console.ReadLine());
- string input = Console.ReadLine();
- int totalValue = 0;
- string convertedValue = "";
- for (int i = 0; i < input.Length; i++)
- {
- char kondio = input[i];
- if (kondio >= 'A' && kondio <= 'Z')
- {
- totalValue += kondio - 64;
- }
- else if (kondio >= 'a' && kondio <= 'z')
- {
- totalValue += kondio - 96;
- }
- else
- {
- totalValue += kondio;
- }
- }
- ////////////////////////////
- do
- {
- //convertedValue = (totalValue % numeralSystem) + convertedValue; kazvame mu izchisli mi novata stoinost i primerno 6 i mi q svurji/ konkatenirai s starata primerno 1 natrupvame stringa 6 + 1 = 61 string
- // convertedValue += (totalValue % numeralSystem); a ako e taka stava stara stoinost 1 mi e otpred i mi q svurji s novata stoinost 6 koqto e otzad i stava 1 + 6 =16
- convertedValue = (totalValue % numeralSystem) + convertedValue;//tuk izpisvame chislata// tuk delim procentno % total value primer 288 % 7 = 1 i otzad poneje e string prosoto go zapisva konkatenira otzad pri purvoto zavurtane 1 pri vtoroto 41 % 7= 6 i pri 3 zavurtane 5 % 7 = 5
- totalValue /= numeralSystem;// tuk do koga da go vurti kolko puti da go vurti// tuk delim totalValue na numeralSystem dokaot stignem do 1 1 zavurtane 288 / 7 = 41 vtoroto zavurtane 41 / 7 = 5 tretoto zavurtane 5 / 7 = 0
- }
- while (totalValue != 0);// kogato celochislenata stoinost stane 0 prekusvame // ne e ravno na 0 zatova e !=0 da e razlichno ot 0 da kajem 4e moje da smqtame i otricatelni chisla
- Console.WriteLine(numeralSystem.ToString() + input.Length.ToString() + convertedValue);// pravim numeralSystem.ToString() zashtoto e int i trugva da mi subira a na men mi trqbva string za da ne mi subira 7 numeralSystem s input.Lenght 9 za to g pravim .ToString() outputa prosot konkatenirame stringove
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement