Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- items ~= 1.23;
- items ~= 45.6;
- for (int i = 0; i != items.length; ++i) {
- writeln("Item ", i + 1, ": ", items[i]);
- }
- writefln("Item %d:%9.02f", i + 1, items[i]);
- writefln("Binary : %b", value);
- writefln("Octal : %o", value);
- writefln("Hexadecimal: %x", value);
- writefln("Decimal : %d", value);
- double value = 123.456789;
- writefln("with e: %e", value);
- writefln("with f: %f", value);
- writefln("with g: %g", value);
- writefln("with a: %a", value);
- bool b = true;
- int i = 365;
- double d = 9.87;
- string s = "formatted";
- auto o = File("test_file", "r");
- int[] a = [ 2, 4, 6, 8 ];
- writefln("bool : %s", b);
- writefln("int : %s", i);
- writefln("double: %s", d);
- writefln("string: %s", s);
- writefln("object: %s", o);
- writefln("array : %s", a);
- int value = 100;
- writefln("In a field of 10 characters:%10s", value);
- writefln("In a field of 5 characters :%5s", value);
- double value = 1234.56789;
- writefln("%.8g", value);
- writefln("%.3g", value);
- writefln("%.8f", value);
- writefln("%.3f", value);
- auto number = 0.123456789;
- writefln("Number: %.*g", 4, number);
- int value = 123;
- writefln("Normally right-aligned:|%10d|", value);
- writefln("Left-aligned:|%-10d|", value);
- writefln("No effect for negative values : %+d", -50);
- writefln("Positive value with the + flag : %+d", 50);
- writefln("Positive value without the + flag: %d", 50);
- writefln("Octal starts with 0 : %#o", 1000);
- writefln("Hexadecimal starts with 0x : %#x", 1000);
- writefln("Contains dot even when unnecessary: %#g", 1f);
- writefln("Rightmost zeros are printed : %#g", 1.2);
- writefln("In a field of 8 characters: %08d", 42);
- writefln("No effect for negative values: % d", -34);
- writefln("Positive value with space : % d", 56);
- writefln("Positive value without space : %d", 56);
- writefln("%1$d %1$x %1$o %1$b", 42);
- writefln("There are %s students in room %s.", count, room);
- auto format = (language == "en"
- ? "There are %s students in room %s."
- : "%s студентов присутствует в аудитории %s.");
- writefln(format, count, room);
- auto format = (language == "en"
- ? "There are %1$s students in room %2$s."
- : "В аудитории %2$s присутствует %1$s студентов.");
- writefln(format, count, room);
- import std.stdio;
- import std.string;
- void main()
- {
- write("Как вас зовут? ");
- auto name = chomp(readln());
- auto result = format("Привет %s!", name);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement