221V 4 дней назад
Родитель
Сommit
4b5f851c8f
1 измененных файлов с 31 добавлено и 30 удалено
  1. 31 30
      exercises/036_enums2.zig

+ 31 - 30
exercises/036_enums2.zig

@@ -28,37 +28,38 @@ const std = @import("std");
 //     #RRGGBB
 //     #RRGGBB
 //
 //
 // Please define and use a pure blue value Color:
 // Please define and use a pure blue value Color:
-const Color = enum(u32) {
-    red = 0xff0000,
-    green = 0x00ff00,
-    blue = ???,
+const Color = enum(u32){
+  red = 0xff0000,
+  green = 0x00ff00,
+  blue = 0x0000ff,
 };
 };
 
 
-pub fn main() void {
-    // Remember Zig's multi-line strings? Here they are again.
-    // Also, check out this cool format string:
-    //
-    //     {x:0>6}
-    //      ^
-    //      x       type ('x' is lower-case hexadecimal)
-    //       :      separator (needed for format syntax)
-    //        0     padding character (default is ' ')
-    //         >    alignment ('>' aligns right)
-    //          6   width (use padding to force width)
-    //
-    // Please add this formatting to the blue value.
-    // (Even better, experiment without it, or try parts of it
-    // to see what prints!)
-    std.debug.print(
-        \\<p>
-        \\  <span style="color: #{x:0>6}">Red</span>
-        \\  <span style="color: #{x:0>6}">Green</span>
-        \\  <span style="color: #{}">Blue</span>
-        \\</p>
-        \\
+pub fn main() void{
+  // Remember Zig's multi-line strings? Here they are again.
+  // Also, check out this cool format string:
+  //
+  //     {x:0>6}
+  //      ^
+  //      x       type ('x' is lower-case hexadecimal)
+  //       :      separator (needed for format syntax)
+  //        0     padding character (default is ' ')
+  //         >    alignment ('>' aligns right)
+  //          6   width (use padding to force width)
+  //
+  // Please add this formatting to the blue value.
+  // (Even better, experiment without it, or try parts of it
+  // to see what prints!)
+  std.debug.print(
+    \\<p>
+    \\  <span style="color: #{x:0>6}">Red</span>
+    \\  <span style="color: #{x:0>6}">Green</span>
+    \\  <span style="color: #{x:0>6}">Blue</span>
+    \\</p>
+    \\
     , .{
     , .{
-        @intFromEnum(Color.red),
-        @intFromEnum(Color.green),
-        @intFromEnum(???), // Oops! We're missing something!
-    });
+    @intFromEnum(Color.red),
+    @intFromEnum(Color.green),
+    @intFromEnum(Color.blue), // Oops! We're missing something!
+  });
 }
 }
+