ob-C-test.org 3.9 KB

a collection of examples for ob-C tests

Simple tests

  std::cout << 42;
  return 0;
  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

  for (int i=1; i<3; i++) {
    std::cout << i << '\n';
  }
  return 0;
  foreach (i; 1..3)
    writefln ("%s", i);

Matrix

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

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<tinomogen_rows; i++) {
    for (j=0; j<tinomogen_cols; j++)
      printf ("%s ", tinomogen[i][j]);
    printf ("\n");
  }
  printf ("Friday %s\n", tinomogen_h(4,"day"));
  return 0;
}
import std.stdio;
void main()
{
  for (int i=0; i<tinomogen_rows; i++) {
    for (int j=0; j<tinomogen_cols; j++)
      writef ("%s ", tinomogen[i][j]);
    writeln();
  }
  writefln ("Friday %s", tinomogen_h(4,"day"));
}

Output

std::cout << "\"line 1\"\n";
std::cout << "\"line 2\"\n";
std::cout << "\"line 3\"\n";