Giter Club home page Giter Club logo

uebung-042's Introduction

Uebung-042 -- ASCII Tabelle

📎Angabe .pdf

📊 Lernziele:

🧮 Aufgabenstellung:

  • Schreiben Sie ein Programm, welches die druckbaren Zeichen des ASCII Codes, samt der entsprechende INT und HEX Zahl ausgibt.
  • Die Druckbaren Zeichen beginnen bei dezimal 32 und enden bei dezimal 127

🔎 Ausgabe Bsp.

Exemplarisch die ersten 15 Zeilen der Ausgabe …

Benutzerschnittstelle:
Ausgabebeispiel 📎

… muss fortgesetzt werden bis zum Code 127


SPOILER Lösung :

🖥 Ausgabe:

meine Ausgabe:
Ausgabe 📎

💾 C# - Programm:

👉 ausklappen 👈
namespace ASCIItable        //  
{                           //
 public class Program      //
 {                         //
   static void Main()      //
   {
     ///*----------------------- console_settings ------------------------*///
     const int cWidth = 53;                     //  console width
     const int cHeight = 30;                    //  & height
     Console.SetWindowSize(cWidth, cHeight);    //
     Console.OutputEncoding = Encoding.UTF8;    //  Unicode Symbols
     /*----------------------------- CONSTANTES ----------------------------*/
     const int firstASCII = 32;
     const int lastASCII = 127;
     /*----------------------------- VARIABLES -----------------------------*/
     int index, hexIndex = 3,
         decimalNumber,
         hexRemainder;

     char printChar;
     char[] hexDigit = new char[hexIndex + 1];

     string outputCode,
            outHex;
     string[] outputLine = new string[lastASCII - firstASCII + 1];

     /*-------------------------------- HEAD -------------------------------*/
     Console.Clear();
     Console.Write("\n                   ASCII Tabelle                     " +
     /* cWidth: */ "\n==========================-==========================");

     for (index = 0; index < (lastASCII - firstASCII + 1); index++)
     {
       //  add Symbol & Prefix to Line
       printChar = Convert.ToChar(firstASCII + index);
       outputLine[index] = "    Zeichen: " + printChar;

       //  add Decimal & Prefix + Suffix to Line
       decimalNumber = firstASCII + index;
       outputCode = "    Code: " + Convert.ToString(decimalNumber).PadLeft(3) + " (dez)    ";
       outputLine[index] = outputLine[index] + outputCode;

       //  add Hex & Prefix + Suffix to Line
       outHex = ""; hexIndex = 0;
       while (decimalNumber % 16 >= 0 && hexIndex < 4)
       {
         hexRemainder = decimalNumber % 16;
         hexDigit[hexIndex] = (char)(hexRemainder < 10 ? hexRemainder + '0' : hexRemainder - 10 + 'A');
         outHex = hexDigit[hexIndex] + outHex;
         decimalNumber = decimalNumber / 16;
         hexIndex++;
       }
       outputLine[index] = outputLine[index] + outHex + " (hex)    ";
     }
     //  output:
     for (index = 0; index < (lastASCII - firstASCII + 1); index++)
     {
       Console.Write($"\n {outputLine[index]}");
     }
     /*-------------------------------- END --------------------------------*/
     Console.Write("\n Zum beenden Eingabetaste drücken..");
     Console.ReadLine();    //  wait for [enter]
     Console.Clear();       //
   }
 }
}

[..weiterführende Quelle..]

-->

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.