Advertisement
sergezhu

Untitled

Mar 30th, 2023
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. Console.InputEncoding = Encoding.Unicode;
  2. Console.OutputEncoding = Encoding.Unicode;
  3.  
  4. bool loopExitFlag = false;
  5.  
  6. while ( !loopExitFlag )
  7. {
  8.     Console.Write( "a = " );
  9.     string aRaw = Console.ReadLine();
  10.     int a = int.Parse( aRaw );
  11.  
  12.     Console.Write( "b = " );
  13.     string bRaw = Console.ReadLine();
  14.     int b = int.Parse( bRaw );
  15.  
  16.     Console.WriteLine( $"a = {a}, b = {b}" );
  17.     Console.WriteLine( $"SWAP" );
  18.  
  19.     (a, b) = (b, a);
  20.  
  21.     Console.WriteLine( $"a = {a}, b = {b}\n" );
  22.  
  23.     Console.WriteLine( "Continue? Enter 'n' for exit" );
  24.     string continueAnswer = Console.ReadLine();
  25.     string exitAnswer = "n";
  26.  
  27.     loopExitFlag = string.Equals( continueAnswer, exitAnswer );
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement