Git Product home page Git Product logo

uebung-038's Introduction

Uebung-038 -- Reverse String

Lernziele:

  • Stringbearbeitung

Aufgabenstellung:

Schreiben Sie ein Programm, welches vom Benutzer einen beliebigen Text einliest, diesen umkehrt und anschließend auf die Konsole ausgibt.

Hinweis:

Die Benutzereingaben dürfen im gesamten Programm nicht verändert werden und müssen erhalten bleiben. Zur Lösung dieser Aufgabe dürfen Sie nicht die Standard-Methoden von String verwenden!

Beispiel:

Eingabe: Hallo Max, wie geht’s?

Ausgabe: ?s’theg eiw, xaM ollaH


SPOILER

Tip

[C#] Visual Studio :

namespace StringReverse     //  
{                           //
 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

     /*----------------------------- VARIABLES -----------------------------*/
     string userInput;
     int index,
         lenght = 0;
     /*-------------------------------- HEAD -------------------------------*/
     Console.Clear();
     Console.Write("\n                  Reverse String                     " +
     /* cWidth: */ "\n=====================================================");

     /*---[in:]-------------------- PROMPT_USER ----------------------------*/
     Console.Write("\n Geben Sie einen Text ein.");    //  

     /*----------------------------- GET_INPUT -----------------------------*/
     userInput = Console.ReadLine();              //  get input + [enter]
                                                  //
     foreach (char letter in userInput)
     { lenght++; }
     Console.Write($"\n Länge:{lenght}\n\n");

     char[] charsInput = new char[lenght];

     for (int i = 0; i < lenght; i++)
     {
       char letter = userInput[i];
       charsInput[i] = letter;
     }

     /*---[out:]--------------------- SOLUTION -----------------------------*/
     index = lenght - 1;
     do
     {
       Console.Write($"{charsInput[index]}");
       index--;
     } while (index >= 0);

     /*-------------------------------- END --------------------------------*/
     Console.Write("\n Zum beenden Eingabetaste drücken..");
     Console.ReadLine();    //  wait for [enter]
     Console.Clear();       //
   }
 }
}

uebung-038's People

Contributors

ixi-enki avatar

Watchers

 avatar

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.