Results 1 to 25 of 44
Thread: ?
Hybrid View
-
20th January 2011 20:56 #1
?
!
1-2 , 2-3 ,
.
( ) . -
.
C# , ...
.
Extension StringBuilder-Code:using System; using System.Numerics; using System.Text; using Extension.String.Reverse; namespace BinaryConverter { class BinaryConverter { static int HornerScheme(int convertionSystem, string numberForConvert) { int converted = 0; if (convertionSystem < 10) { converted = (int)numberForConvert[0] - 48; for (int i = 1; i < numberForConvert.Length; i++) { converted = convertionSystem * converted + (int)numberForConvert[i] - 48; } } else if (convertionSystem > 10) { if ((int)numberForConvert[0] > 64) { converted = (int)numberForConvert[0] - 55; } else converted = (int)numberForConvert[0] - 48; for (int i = 1; i < numberForConvert.Length; i++) { if ((int)numberForConvert[i] > 64) { converted = convertionSystem * converted + (int)numberForConvert[i] - 55; } else { converted = convertionSystem * converted + (int)numberForConvert[i] - 48; } } } return converted; } static int FromAnyToDecimal(string numberToConvert) { Console.WriteLine("Input the system in which the number is."); int numberConvertionSystem; bool isCorrect = int.TryParse(Console.ReadLine(), out numberConvertionSystem); if (!isCorrect) { throw new FormatException("The system is not in a valid format."); } return HornerScheme(numberConvertionSystem, numberToConvert); } static StringBuilder ConvertToAny(int convertionSystem, BigInteger numberForConvert) { StringBuilder convertedNumber = new StringBuilder(); do { if (numberForConvert % convertionSystem > 9) { convertedNumber.Append((char)(numberForConvert % convertionSystem + 55)); } else { convertedNumber.Append(numberForConvert % convertionSystem); } numberForConvert /= convertionSystem; } while (numberForConvert >= convertionSystem); if (numberForConvert > 9 && numberForConvert != 0) { convertedNumber.Append((char)(numberForConvert + 55)); } else if (numberForConvert <= 9 && numberForConvert != 0) { convertedNumber.Append(numberForConvert); } return convertedNumber.Reversed(); } static StringBuilder FromDecimalToAny(BigInteger numberToConvert) { Console.WriteLine("Input the system to which you want to convert."); int numberConvertionSystem; bool isCorrect = int.TryParse(Console.ReadLine(), out numberConvertionSystem); if (!isCorrect) { throw new FormatException("The system is not in a valid format."); } return ConvertToAny(numberConvertionSystem, numberToConvert); } static void Main(string[] args) { Console.WriteLine("Input the number you want to convert."); BigInteger number; bool isCorrect = BigInteger.TryParse(Console.ReadLine(), out number); if (!isCorrect) { throw new ArgumentException("The value of the number is string."); } Console.WriteLine( "Do you want to convert the number from any system to decimal or the opposite?" + "\nType any for the first option or other for the second option."); string answer = Console.ReadLine(); switch (answer) { case "any": Console.WriteLine(FromAnyToDecimal(number.ToString())); break; case "other": Console.WriteLine(FromDecimalToAny(number)); break; default: throw new ArgumentException("The answer is not valid."); } } } }
!!!Code:using System.Text; namespace Extension.String.Reverse { public static class ExtensionStringReverse { public static StringBuilder Reversed(this StringBuilder str) { StringBuilder reversedWord = new StringBuilder(); for (int i = str.Length - 1; i >= 0; i--) { reversedWord.Append(str[i]); } return reversedWord; } } }
-
20th January 2011 22:22 #2
-
20th January 2011 22:44 #3
-
20th January 2011 22:47 #4
.
:
statement if-, .
., :
:Code:if (numberForConvert % convertionSystem > 9) { convertedNumber.Append((char)(numberForConvert % convertionSystem + 55)); }
Code:if (numberForConvert % convertionSystem > 9) convertedNumber.Append((char)(numberForConvert % convertionSystem + 55));
. HWBG !
-
20th January 2011 22:51 #5
-
20th January 2011 22:58 #6
, , . :
Code:void * _nowhere(){ return NULL; }EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|
-
20th January 2011 23:08 #7
-
20th January 2011 23:42 #8
-
20th January 2011 23:55 #9
-
21st January 2011 00:04 #10
-
20th January 2011 23:14 #11
19001200 8
,
EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|
-
20th January 2011 23:24 #12
-
20th January 2011 23:39 #13Registered User
Join Date: Oct:2003
Location:
Posts: 4,317
-
20th January 2011 23:45 #14
!
, .
BinaryConverter, . . .
, .
""
bsb
-
20th January 2011 23:54 #15Registered User
Join Date: Jul:2004
Location:
Posts: 621
.
:
1) "" 48, 64 (65) .. - . , , , :
2) static int HornerScheme() convertionSystem == 10Code:// /++ if (numberForConvert[0] >= '') { converted = 10 + numberForConvert[0] - ''; } else converted = numberForConvert[0] - '0';
3) , "int converted = 0;" , :
(i == 0) 1-2 , - -Code:if (convertionSystem < 10) { for (int i = 0; i < numberForConvert.Length; i++) { converted = convertionSystem * converted + (int)numberForConvert[i] - 48; } }
-
21st January 2011 02:27 #16
.
, . . , , , - .
flame wars , - . 0.0001% , .
" " .. .. 2 1 , 1/3 , , DPI etc., , 19- 2 150% DPI, 14,
.
, . , , . , , , , IDE , , { } , -
.
( ) , , , . 4-5 , - .
-
21st January 2011 02:47 #17
/. C() , -, . / . , , "" , , , , .
EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|
-
21st January 2011 09:53 #18
.
- .
:
50% IF- .Code:if ($var) echo $var;
ps - , , :
Code:if (var>=5) var=(var2)?3:2; // var=func(a,b,c);Hey, mother, I come bearing a gift. I'll give you a hint. It's in my diaper and it's not a toaster.
.
-
21st January 2011 10:08 #19
, . , , , , ..
: XaMaB; . 0.42
In God we Trust (all others must submit a X.509 certificate). , ()
-
21st January 2011 10:39 #20Registered User
Join Date: Aug:2006
Location:
Posts: 4,052
auto-formater. ,
-
21st January 2011 11:16 #21
, , , / .
( java, , ). , statement, , . , - , .
, . -, .. HWBG !
-
21st January 2011 11:49 #22Registered User
Join Date: Aug:2006
Location:
Posts: 4,052
-
21st January 2011 11:32 #23
-
21st January 2011 12:21 #24
- , - 2-3 - - .
"else" 1 , , .
" , "
- , 2 , , ( ), .
, .
-
21st January 2011 14:41 #25Registered User
Join Date: Jul:2005
Location: Sofiq
Posts: 2,798




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in