← pynet

course2_ex1

bd7972e015d2519f94982358c9e2796bddb7f46d · ovidiucs · Sep 14, 2015 21:50

+13 · 1 file changed

  • course_2/ex1_input_network.d +13 −0
diff --git a/course_2/ex1_input_network.d b/course_2/ex1_input_network.d
new file mode 100644
index 0000000..75823f4
--- /dev/null
+++ b/course_2/ex1_input_network.d
@@ -0,0 +1,13 @@
+import std.stdio;
+import std.string;
+import std.conv;
+import std.format;
+
+void main()
+{
+   write(" > " );
+   string ip_address = chomp(readln);
+   int firstOctet = to!int(split(ip_address,'.')[0]);
+   writeln("NETWORK NUMBER FIRST_OCTET_BINARY FIRST_OCTET_HEX");
+   writefln("|%s| |%-17.08b| |%-17x|", ip_address, firstOctet, firstOctet);
+}