Practice Exercises C# Sharp

Practice Exercises C# Sharp

Learn to program performing exercises with C# Sharp

12 Lessons C# Sharp with the Solutions - 228 Exercises C# Sharp with the solutions
For Beginners, Intermediates and Advanceds


The human knowledge belongs to the world
¡The infomation should be free!

5 Estrellas - 9986Total Votos

Banner - Practice Exercises C# Sharp


Lesson 4:

Structures and Strings


Exercise 4.16:

Banner


Objetive:

Create a C# program to imitate the basic Unix SysV "banner" utility, able to display big texts like these:



Google Ads


Source Code:


using System;
public class Banner
{
    static void Main(string[] args)
    {
        string[] esqueleto =  
        {  
            "         ###  ### ###  # #   ##### ###   #  ##     ###  ", 
            "         ###  ### ###  # #  #  #  ## #  #  #  #    ###  ", 
            "         ###   #   # ########  #   ### #    ##      #   ", 
            "          #            # #   #####    #    ###     #    ", 
            "                     #######   #  #  # ####   # #       ", 
            "         ###           # #  #  #  # #  # ##    #        ", 
            "         ###           # #   ##### #   ### #### #       ", 
            "   ##    ##                                            #", 
            "  #        #   #   #    #                             # ", 
            " #          #   # #     #                            #  ", 
            " #          # ####### #####   ###   #####           #   ", 
            " #          #   # #     #     ###           ###    #    ", 
            "  #        #   #   #    #      #            ###   #     ", 
            "   ##    ##                   #             ###  #      ", 
            "  ###     #    #####  ##### #      ####### ##### #######", 
            " #   #   ##   #     ##     ##    # #      #     ##    # ", 
            "#     # # #         #      ##    # #      #          #  ", 
            "#     #   #    #####  ##### #    # ###### ######    #   ", 
            "#     #   #   #            ########      ##     #  #    ", 
            " #   #    #   #      #     #     # #     ##     #  #    ", 
            "  ###   ##### ####### #####      #  #####  #####   #    ", 
            " #####  #####    #     ###      #           #     ##### ", 
            "#     ##     #  ###    ###     #             #   #     #", 
            "#     ##     #   #            #     #####     #        #", 
            " #####  ######         ###   #                 #     ## ", 
            "#     #      #   #     ###    #     #####     #     #   ", 
            "#     ##     #  ###     #      #             #          ", 
            " #####  #####    #     #        #           #       #   ", 
            " #####    #   ######  ##### ###### ############## ##### ", 
            "#     #  # #  #     ##     ##     ##      #      #     #", 
            "# ### # #   # #     ##      #     ##      #      #      ", 
            "# # # ##     ####### #      #     ######  #####  #  ####", 
            "# #### ########     ##      #     ##      #      #     #", 
            "#      #     ##     ##     ##     ##      #      #     #", 
            " ##### #     #######  ##### ###### ########       ##### ", 
            "#     #  ###        ##    # #      #     ##     ########", 
            "#     #   #         ##   #  #      ##   ####    ##     #", 
            "#     #   #         ##  #   #      # # # ## #   ##     #", 
            "#######   #         ####    #      #  #  ##  #  ##     #", 
            "#     #   #   #     ##  #   #      #     ##   # ##     #", 
            "#     #   #   #     ##   #  #      #     ##    ###     #", 
            "#     #  ###   ##### #    # ########     ##     ########", 
            "######  ##### ######  ##### ########     ##     ##     #", 
            "#     ##     ##     ##     #   #   #     ##     ##  #  #", 
            "#     ##     ##     ##         #   #     ##     ##  #  #", 
            "###### #     #######  #####    #   #     ##     ##  #  #", 
            "#      #   # ##   #        #   #   #     # #   # #  #  #", 
            "#      #    # #    # #     #   #   #     #  # #  #  #  #", 
            "#       #### ##     # #####    #    #####    #    ## ## ", 
            "#     ##     ######## ##### #       #####    #          ", 
            " #   #  #   #      #  #      #          #   # #         ", 
            "  # #    # #      #   #       #         #  #   #        ", 
            "   #      #      #    #        #        #               ", 
            "  # #     #     #     #         #       #               ", 
            " #   #    #    #      #          #      #               ", 
            "#     #   #   ####### #####       # #####        #######", 
            "  ###                                                   ", 
            "  ###     ##   #####   ####  #####  ###### ######  #### ", 
            "   #     #  #  #    # #    # #    # #      #      #    #", 
            "        ###### #    # #      #    # #      #      #  ###", 
            "    #   #    # #####  #      #    # #####  #####  #     ", 
            "        #    # #    # #    # #    # #      #      #    #", 
            "        #    # #####   ####  #####  ###### #       #### ", 
            "                                                        ", 
            " #    #    #        # #    # #      #    # #    #  #### ", 
            " #    #    #        # #   #  #      ##  ## ##   # #    #", 
            " ######    #        # ####   #      # ## # # #  # #    #", 
            " #    #    #        # #  #   #      #    # #  # # #    #", 
            " #    #    #   #    # #   #  #      #    # #   ## #    #", 
            " #    #    #    ####  #    # ###### #    # #    #  #### ", 
            "                                                        ", 
            " #####   ####  #####   ####   ##### #    # #    # #    #", 
            " #    # #    # #    # #         #   #    # #    # #    #", 
            " #    # #    # #    #  ####     #   #    # #    # #    #", 
            " #####  #  # # #####       #    #   #    # #    # # ## #", 
            " #      #   #  #   #  #    #    #   #    #  #  #  ##  ##", 
            " #       ### # #    #  ####     #    ####    ##   #    #", 
            "                       ###     #     ###   ##    # # # #", 
            " #    #  #   # ###### #        #        # #  #  # # # # ", 
            "  #  #    # #      #  #        #        #     ## # # # #", 
            "   ##      #      #  ##                 ##        # # # ", 
            "   ##      #     #    #        #        #        # # # #", 
            "  #  #     #    #     #        #        #         # # # ", 
            " #    #    #   ######  ###     #     ###         # # # #"
    };

    Console.Write("Tell a string:");
    string Entry = Console.ReadLine();

    byte j=1;
    char Letra;
    int[] CodigoAscii = new int[Entry.Length];

    for (int i = 0; i < Entry.Length; i++)
    {
        Letra = Convert.ToChar(Entry.Substring(i, j));
        CodigoAscii[i] = Convert.ToInt32(Letra);
    }

    int AnchoLetras = 7,AltoLetra = 7;
    int numeroAscii = 32;
    int countLineas = 0, countLetras = 0,countPosiciones = 0;
    bool LetraEncontrada = false;
    string[] cadena = new string[AltoLetra];

    for (int i = 0; i < CodigoAscii.Length; i++)
    { 
        // Recorro todos las filas del esqueleto de letras
        for (int row = 0; row < esqueleto.Length; row++)
        {
            if (countLetras == 8)
            {
                row += AltoLetra-1;
                countLetras = 0;
                countPosiciones = 0;
            }
            //Si no la encuentro tengo que ir aumento la posicion y el numero ascii 
            while ((!LetraEncontrada) && (countLetras < 8))
            {
                if (CodigoAscii[i] == numeroAscii)
                    LetraEncontrada = true;
                else
                {
                    numeroAscii++;
                    countPosiciones += AnchoLetras;
                    countLetras++;
                }   
            }
            //Si la e encontrado y no tengo las 7 lineas de la letra
            if ( (LetraEncontrada) && (countLineas < 7) )
            {
                if (i > 0)
                    cadena[countLineas] = cadena[countLineas] + esqueleto[row].Substring(countPosiciones, AnchoLetras);
                else
                    cadena[countLineas] = esqueleto[row].Substring(countPosiciones, AnchoLetras);
                countLineas++;
            }
        }
        countLineas = 0;
        numeroAscii = 32;
        LetraEncontrada = false;
        countPosiciones = 0;
        countLetras = 0;
    }  

    //Muestro
    for (int i = 0; i < cadena.Length; i++)
    Console.WriteLine(cadena[i]);
    }
}


                
Exercisey 4.16

Google Ads







Privacy Policy:



Google uses associated advertising companies to serve ads when it visits our website. These companies may use the information they obtain from your visits to this and other websites (not including your name, address, email address, or phone number) to provide you with announcements about products and services that interest you. If you would like to learn more about this practice and know your options to prevent these companies from using this information. Click in... Privacy and Terms of Google.

Cookies

This site uses Google cookies to provide its services, to personalize advertisements and to analyze traffic. Google receives information about your use of this website. More information in... Privacy and Terms of Google.