ob-C-test.org 3.6 KB

Simple tests

:PROPERTIES: :ID: fa6db330-e960-4ea2-ac67-94bb845b8577 :END:

std::cout << 42; return 0;

writefln ("%s", 42);

std::cout << q; return 0;

writefln ("%s", q);

std::cout << p+q; return 0;

writefln ("%s", p+q);

std::cout << q << ' ' << std::strlen(q); return 0;

writefln ("%s %s", q, q.length);

std::cout << N; return 0;

Array

:PROPERTIES: :ID: 2df1ab83-3fa3-462a-a1f3-3aef6044a874 :END:

for (int i=1; i<3; i++) { std::cout << i << '\n'; } return 0;

foreach (i; 1..3) writefln ("%s", i);

Matrix

:PROPERTIES: :ID: cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5 :END:

1 2
3 4

std::cout << a[0] << a[1] << sizeof(a)/sizeof(*a) << '\n';

writefln ("%s%s%s", a[0], a[1], a.length);

std::cout << a[0] << a[1] << sizeof(a)/sizeof(*a) << '\n';

writefln ("%s%s%s", a[0], a[1], a.length);

std::cout << q[0][0] << ' ' << q[1][0] << '\n' << q[0][1] << ' ' << q[1][1] << '\n'; // transpose

writefln ("%s %s", q[0][0], q[1][0]); writefln ("%s %s", q[0][1], q[1][1]); // transpose

Inhomogeneous table

:PROPERTIES: :ID: e112bc2e-419a-4890-99c2-7ac4779531cc :END:

| day | quty | |-----------+------| | monday | 34 | | tuesday | 41 | | wednesday | 56 | | thursday | 17 | | friday | 12 | | saturday | 7 | | sunday | 4 |

int main() { int i, j; for (i=0; i

import std.stdio; void main() { for (int i=0; i