Logo
PLAYGROUND

Machine

CPU 16GB RAM

Language

C/C++

Version 0.8.0



  • reverse.c
  • checksum.c
  • sha256.c
  • fibonacci.rs
  • fizzbuzz.rs
  • palindrome.rs
  • wasm.c
  • lib.rs

reverse.c


const unsigned EOF = 0xFFFFFFFF;
#define BUF_LEN 2048

int main() {
unsigned buf[BUF_LEN];
unsigned len = 0;
while (len < BUF_LEN) {
unsigned c = __builtin_valida_read_advice();
if (c == EOF) {
break;
} else {
buf[len] = c;
len++;
}
}
for (unsigned i = 0; i < len / 2; i++) {
unsigned j = len - 1 - i;
unsigned tmp = buf[i];
buf[i] = buf[j];
buf[j] = tmp;
}
for (unsigned i = 0; i < len; i++) {
__builtin_valida_write(buf[i]);
}
}

Inputs


Output