Jump to content

Subleq: Difference between revisions

1,141 bytes added ,  5 years ago
m (→‎{{header|REXX}}: added highlighting to the REXX header section.)
Line 426:
Hello, world!
</pre>
 
=={{header|C#|C sharp}}==
{{trans|Java}}
<lang csharp>using System;
 
namespace Subleq {
class Program {
static void Main(string[] args) {
int[] mem = {
15, 17, -1, 17, -1, -1, 16, 1, -1, 16,
3, -1, 15, 15, 0, 0, -1, 72, 101, 108,
108, 111, 44, 32, 119, 111, 114, 108, 100, 33,
10, 0,
};
 
int instructionPointer = 0;
 
do {
int a = mem[instructionPointer];
int b = mem[instructionPointer + 1];
 
if (a == -1) {
mem[b] = Console.Read();
}
else if (b == -1) {
Console.Write((char)mem[a]);
}
else {
mem[b] -= mem[a];
if (mem[b] < 1) {
instructionPointer = mem[instructionPointer + 2];
continue;
}
}
 
instructionPointer += 3;
} while (instructionPointer >= 0);
}
}
}</lang>
{{out}}
<pre>Hello, world!</pre>
 
=={{header|COBOL}}==
1,452

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.