hello world.
import std.stdio;
void main() {
//write("hello world.\n");
writeln("hello world.");
}
void main() {
printf("hello world.\0".ptr);
}
import std.stdio;
void main() {
writeln("h"~"e"~"l"~"l"~"o"~cast(char)0x20~"w"~"o"~"r"~"l"~"d"~".");
}
import std.stdio;
void main(string[] args) {
try writeln(args[1]);
catch(Exception) writeln(`hello world?`);
}
import std.stdio;
import std.file;
void main() {
auto buf = read("msg.txt".idup);
writeln(buf);
}
import std.stdio;
void main() {
string[] list = [
"5:lr", "4:ow", "2:ll",
"3: o", "6:.d", "1:eh",
];
for(auto i=0; i < list.length; i++)
list[i] = list[i][0..2]~list[i][3]~list[i][2];
string hello;
foreach(s; list.sort)
hello ~= s[2..$];
writeln(hello);
}
import std.stdio;
import std.string;
struct HELLO {
alias HELLO MyStruct;
string first;
string second;
string third;
static MyStruct opCall(string s) {
MyStruct mys;
with(mys) {
first = split(s, "-")[0];
second = split(s, "-")[1];
third = split(s, "-")[2];
}
return mys;
}
}
void main() {
HELLO s = "HELLO- -WORLD.".tolower();
writeln(s.tupleof);
}
import std.stdio;
import std.uni;
interface IConverter {
private string Big2Small(string);
}
abstract class CConverter: IConverter {
private {
string Big2Small(string s) {
auto small = s.dup;
foreach(i, c; s)
if(isUniUpper(c)) small[i] = toUniLower(c);
return small.idup;
}
string plus(string, string);
}
}
class PlusPeriod: CConverter {
private {
string plus(string left, string right) {
if(!right && !right.length)
return left ~ ".";
return left ~ right;
}
string s;
}
this(string s) {
this.s = Big2Small(s);
}
override string toString() {
return plus(s, null);
}
}
void main() {
writeln(new PlusPeriod("HELLo woRLd"));
}
hello world.
↑全部これ