<?php
$vetor = [];
while (($linha = fgets(STDIN)) !== false) {
    $linha = trim($linha);
    if ($linha === "") continue;
    $partes = explode(" ", $linha);
    $operacao = intval($partes[0]);
    if ($operacao == 0) break;
    if ($operacao == 1) {
        $x = intval($partes[1]);
        $vetor[] = $x;
    } elseif ($operacao == 2) {
        $k = intval($partes[1]) - 1;
        $tamanho = count($vetor);
        if ($k >= 0 && $k < $tamanho) {
            for ($i = $k; $i < $tamanho - 1; $i++) {
                $vetor[$i] = $vetor[$i + 1];
            }
            array_pop($vetor);
        }
    } elseif ($operacao == 3) {
        $tamanho = count($vetor);
        for ($i = 0; $i < $tamanho; $i++) {
            echo $vetor[$i] . ($i < $tamanho - 1 ? " " : "");
        }
        echo PHP_EOL;
    }
}
?>

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: