Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace FormatingExample
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Please, enter how many test cases you would like to run: ");
- int tests = int.Parse(Console.ReadLine());
- short[] a = new short[tests];
- double[] b = new double[tests];
- double[] c = new double[tests];
- string[] columnA = new string[tests];
- for (int i = 0; i < tests; i++)
- {
- System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
- Console.Write("Enter an integer: ");
- a[i] = short.Parse(Console.ReadLine());
- Console.Write("Enter first floating - point number: ");
- b[i] = double.Parse(Console.ReadLine());
- Console.Write("Enter second floating - point number: ");
- c[i] = double.Parse(Console.ReadLine());
- columnA[i] = Convert.ToString(a[i], 2);
- }
- Console.WriteLine("|{0,-10}|{1,10}|{2,10}|{3,-10}|", "Integer a", "Int to bin", "Double 1", "Double 2");
- for (int i = 0; i < tests; i++)
- {
- if (b[i] > (int) b[i] || c[i] > (int) c[i])
- {
- Console.WriteLine("|{0, -10:X}|{1}|{2,10:0.00}|{3,-10:0.000}|", a[i], columnA[i].PadLeft(10, '0'), b[i], c[i]);
- }
- else
- {
- Console.WriteLine("|{0, -10:X}|{1}|{2,10:0.##}|{3,-10:0.###}|", a[i], columnA[i].PadLeft(10, '0'), b[i], c[i]);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement