Advertisement
Guest User

CC

a guest
Jul 24th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.10 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.IO;
  4. using System.Text;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7.  
  8. /**
  9.  * Auto-generated code below aims at helping you parse
  10.  * the standard input according to the problem statement.
  11.  **/
  12. class Solution
  13. {
  14.     static void Main(string[] args)
  15.     {
  16.         string MESSAGE = "Chuck Norris' keyboard has 2 keys: 0 and white space."
  17.  
  18.         // Write an action using Console.WriteLine()
  19.         // To debug: Console.Error.WriteLine("Debug messages...");
  20.         byte[] bajty = Encoding.ASCII.GetBytes(MESSAGE);
  21.         string odpowiedz="";
  22.         string wiadomosc ="";
  23.         int dlugosc=0;
  24.         foreach (byte b in bajty)
  25.         {
  26.          wiadomosc+=Convert.ToString(bajty[dlugosc], 2);    
  27.          dlugosc++;
  28.         }
  29.         Console.Error.WriteLine(MESSAGE);
  30.        
  31.         dlugosc=0;
  32.        
  33.         foreach (char c in wiadomosc)
  34.         {
  35.             dlugosc++;
  36.         }
  37.        
  38.         if(dlugosc<7)
  39.         {
  40.          wiadomosc=wiadomosc.PadLeft(7, '0');
  41.          dlugosc=0;
  42.           foreach (char c in wiadomosc)
  43.         {
  44.             dlugosc++;
  45.         }
  46.          
  47.         }
  48.      
  49.         Console.Error.WriteLine(wiadomosc);
  50.        
  51.         for (int i=0;i<dlugosc;i++)
  52.         {
  53.             if (i!=0)
  54.              if(wiadomosc[i]!=wiadomosc[i-1])
  55.               odpowiedz+=" ";
  56.              
  57.             if(wiadomosc[i]=='0')
  58.             {
  59.               if(i==0)
  60.               {
  61.                odpowiedz+="00 0";
  62.               }
  63.               else if(i!=0)
  64.               if (wiadomosc[i]=='0'&&wiadomosc[i-1]=='0')
  65.                odpowiedz+="0";
  66.               else
  67.                odpowiedz+="00 0";
  68.             }
  69.             else
  70.             {            
  71.              if(i==0)
  72.               {
  73.                odpowiedz+="0 0";
  74.               }
  75.               else if (wiadomosc[i]=='1'&&wiadomosc[i-1]=='1')
  76.                odpowiedz+="0";
  77.               else
  78.                odpowiedz+="0 0";
  79.             }          
  80.         }        
  81.         Console.WriteLine(odpowiedz);
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement