Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- string s = "";
- while (s != "hare")
- {
- Console.Write("Input:");
- s = Console.ReadLine();
- long p = Convert.ToInt64(s);
- s = SizeFormat(p);
- Console.WriteLine(s);
- Console.ReadLine();
- }
- }
- static string SizeFormat(long size)
- {
- string sizeStr = size.ToString();
- string result = "";
- do
- {
- if (sizeStr.Length >= 3)
- {
- result = sizeStr.Substring(sizeStr.Length - 3) + " " + result;
- sizeStr = sizeStr.Remove(sizeStr.Length - 3);
- }
- else
- {
- result = sizeStr.Substring(sizeStr.Length - 1) + " " + result;
- sizeStr = sizeStr.Remove(sizeStr.Length - 1);
- }
- }
- while (sizeStr != "");
- if (result.StartsWith(" "))
- {
- result = result.Substring(1);
- }
- if (result.EndsWith(" "))
- {
- result = result.Substring(0, result.Length - 1);
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement