wtorek, 13 września 2011

Dzień programisty 2011


  1. Uruchamiamy Visual Studio

  2. Tworzymy nowy projekt "Console Application"

  3. Wklejamy poniższy tekst

    using System;
    using System.Text;

    namespace Quine2011
    {
    class Program
    {
    const string q = "dXNpbmcgU3lzdGVtOw0KdXNpbmcgU3lzdGVtLlRleHQ7DQoNCm5hbWVzcGFjZSBRdWluZTIwMTENCnsNCiAgICBjbGFzcyBQcm9ncmFtDQogICAgew0KICAgICAgICBjb25zdCBzdHJpbmcgcSA9ICIyNTYiOw0KICAgICAgICBzdGF0aWMgdm9pZCBNYWluKHN0cmluZ1tdIGFyZ3MpDQogICAgICAgIHsNCiAgICAgICAgICAgIGNvbnN0IHN0cmluZyB4MjU2ID0gIjI1NiI7DQogICAgICAgICAgICBzdHJpbmcgdiA9IEVuY29kaW5nLkRlZmF1bHQuR2V0U3RyaW5nKENvbnZlcnQuRnJvbUJhc2U2NFN0cmluZyhxKSk7DQogICAgICAgICAgICBpbnQgcCA9IHYuSW5kZXhPZih4MjU2KTsNCiAgICAgICAgICAgIENvbnNvbGUuV3JpdGUodi5TdWJzdHJpbmcoMCwgcCkgDQogICAgICAgICAgICAgICAgKyBxIA0KICAgICAgICAgICAgICAgICsgdi5TdWJzdHJpbmcocCArIHgyNTYuTGVuZ3RoKSk7DQogICAgICAgICAgICBDb25zb2xlLlJlYWRLZXkoKTsNCiAgICAgICAgfQ0KICAgIH0NCn0NCg==";
    static void Main(string[] args)
    {
    const string x256 = "256";
    string v = Encoding.Default.GetString(Convert.FromBase64String(q));
    int p = v.IndexOf(x256);
    Console.Write(v.Substring(0, p)
    + q
    + v.Substring(p + x256.Length));
    Console.ReadKey();
    }
    }
    }



  4. Kompilujemy i uruchamiamy

  5. Do zobaczenia za rok