Advertisement
VSZM

TSORT in SPOJ

Jul 7th, 2014
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace TSORT
  6. {
  7.  
  8.     class ContestUtil
  9.     {
  10.         public static int ParseInt(string str)
  11.         {
  12.             str.Trim();
  13.             int ret = 0;
  14.  
  15.             for (int i = 0; i < str.Length; i++)
  16.             {
  17.                 ret += (str[i] - '0') * (int)Math.Pow(10, str.Length - i - 1);
  18.             }
  19.             return ret;
  20.         }
  21.     }
  22.    
  23.     class Program
  24.     {
  25.         static void Main(string[] args)
  26.         {
  27.             int numbers_count = int.Parse(Console.ReadLine());
  28.             int[] numbers = new int[1000000];
  29.  
  30.             int tmp;
  31.             for (int i = 0; i < numbers_count; i++)
  32.             {
  33.                 tmp = ContestUtil.ParseInt(Console.In.ReadLine());
  34.                 numbers[tmp] += 1;
  35.             }
  36.  
  37.  
  38.             StringBuilder sb = new StringBuilder();
  39.  
  40.             for (int i = 0; i < 1000000; i++)
  41.             {
  42.                 for (int j = 0; j < numbers[i]; j++)
  43.                 {
  44.                     sb.AppendLine(i.ToString());
  45.                 }
  46.             }
  47.  
  48.             Console.Write(sb.ToString());
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement