<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="category">
    <category>
      <text>$course$/top/OnlineCompiler.io C++ (português)</text>
    </category>
    <info format="html">
      <text><![CDATA[<p>Questões CodeRunner grátis do OnlineCompiler.io (https://onlinecompiler.io/pt/banco-de-questoes-coderunner), sob a licença CC BY 4.0. Usam os tipos de questão que já vêm com o CodeRunner, então rodam em qualquer servidor Jobe.</p>]]></text>
    </info>
    <idnumber></idnumber>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Área e perímetro do retângulo]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escreva um programa que leia a largura e a altura de um retângulo e imprima a área e o perímetro dele em uma linha, separados por um espaço, cada um com exatamente duas casas decimais.</p><p>A entrada são dois números reais positivos, separados por um espaço ou uma quebra de linha e escritos com ponto decimal (por exemplo, <code>2.5</code>); a saída também usa ponto. Dica: <code>fixed</code> e <code>setprecision</code>, de <code>&lt;iomanip&gt;</code>.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_program</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[#include <iomanip>
#include <iostream>
using namespace std;

int main() {
    double width, height;
    cin >> width >> height;
    cout << fixed << setprecision(2);
    cout << width * height << " " << 2 * (width + height) << endl;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[3 4
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[12.00 14.00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[2.5
4
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[10.00 13.00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[0.5 0.5
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[0.25 2.00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[1.2 3.4
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[4.08 9.20]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[1000000 1000000
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[1000000000000.00 4000000.00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>io</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Dias do mês]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escreva uma função <code>int days_in_month(int month, int year)</code> que devolva o número de dias do mês informado no ano informado, em que <code>month</code> vai de 1 (janeiro) a 12 (dezembro). Fevereiro tem 29 dias em ano bissexto e 28 nos demais. Um ano é bissexto se for divisível por 4, exceto os anos divisíveis por 100 que não são divisíveis por 400: 2000 foi bissexto, 1900 não.</p><p>1 &le; <code>month</code> &le; 12 e 1 &le; <code>year</code> &le; 9999. Um <code>switch</code> sobre o mês funciona bem aqui.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[int days_in_month(int month, int year) {
    switch (month) {
        case 2: {
            bool leap = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
            return leap ? 29 : 28;
        }
        case 4:
        case 6:
        case 9:
        case 11:
            return 30;
        default:
            return 31;
    }
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << days_in_month(1, 2023) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[31]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << days_in_month(2, 2024) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[29]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << days_in_month(2, 2023) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[28]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[for (int m = 1; m <= 12; m++) cout << days_in_month(m, 2023) << " ";
cout << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[31 28 31 30 31 30 31 31 30 31 30 31]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << days_in_month(2, 1900) << " " << days_in_month(2, 2000) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[28 29]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << days_in_month(2, 2100) << " " << days_in_month(2, 2400) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[28 29]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>conditionals</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Tipo de triângulo]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escreva uma função <code>int triangle_type(int a, int b, int c)</code> que receba os comprimentos de três lados e devolva:</p><ul><li>0 se eles não formam um triângulo: algum lado é zero ou negativo, ou algum lado é maior ou igual à soma dos outros dois;</li><li>1 se o triângulo é equilátero (os três lados iguais);</li><li>2 se é isósceles (exatamente dois lados iguais);</li><li>3 se é escaleno (os três lados diferentes).</li></ul><p>Cada argumento está entre &minus;10<sup>9</sup> e 10<sup>9</sup>.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[int triangle_type(int a, int b, int c) {
    if (a <= 0 || b <= 0 || c <= 0) {
        return 0;
    }
    if (a >= b + c || b >= a + c || c >= a + b) {
        return 0;
    }
    if (a == b && b == c) {
        return 1;
    }
    if (a == b || b == c || a == c) {
        return 2;
    }
    return 3;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << triangle_type(3, 4, 5) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[3]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << triangle_type(2, 2, 2) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << triangle_type(5, 5, 8) << " " << triangle_type(8, 5, 5) << " " << triangle_type(5, 8, 5) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[2 2 2]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << triangle_type(1, 2, 3) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << triangle_type(2, 9, 2) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << triangle_type(0, 0, 0) << " " << triangle_type(-3, 4, 5) << " " << triangle_type(1000000000, 1000000000, 1000000000) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0 0 1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>conditionals</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Passos de Collatz]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Comece com um inteiro positivo <i>n</i> e repita este passo até que <i>n</i> seja 1: se <i>n</i> for par, divida-o por 2; se for ímpar, troque-o por 3<i>n</i> + 1. Escreva uma função <code>int collatz_steps(long long n)</code> que devolva o número de passos necessários. Por exemplo, 6 precisa de 8 passos (6, 3, 10, 5, 16, 8, 4, 2, 1), e 1 precisa de 0.</p><p>1 &le; <i>n</i> &le; 10<sup>6</sup>. No caminho, o valor pode passar do limite de <code>int</code>; por isso o parâmetro é <code>long long</code>.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[int collatz_steps(long long n) {
    int steps = 0;
    while (n != 1) {
        if (n % 2 == 0) {
            n /= 2;
        } else {
            n = 3 * n + 1;
        }
        steps++;
    }
    return steps;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << collatz_steps(6) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[8]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << collatz_steps(1) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << collatz_steps(7) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[16]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << collatz_steps(27) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[111]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << collatz_steps(97) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[118]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << collatz_steps(837799) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[524]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>loops</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Maior e menor]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escreva um programa que leia inteiros até ler um 0 e então imprima o maior e o menor dos números que vieram antes do 0, separados por um espaço. O 0 só marca o fim dos dados: ele não é um dos números, e o que vier depois dele é ignorado.</p><p>Pelo menos um número diferente de zero vem antes do 0. Os números podem ser negativos e estão entre &minus;10<sup>9</sup> e 10<sup>9</sup>.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_program</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[#include <iostream>
using namespace std;

int main() {
    int x;
    cin >> x;
    int largest = x;
    int smallest = x;
    while (cin >> x && x != 0) {
        if (x > largest) {
            largest = x;
        }
        if (x < smallest) {
            smallest = x;
        }
    }
    cout << largest << " " << smallest << endl;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[5 3 9 -2 0
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[9 -2]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[-5 -1 -7 0
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[-1 -7]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[42 0
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[42 42]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[3
8
0
100
-100
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[8 3]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[1000000000 -1000000000 0
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[1000000000 -1000000000]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>loops</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Ordenar três variáveis]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escreva uma função <code>void sort_three(int&amp; a, int&amp; b, int&amp; c)</code> que reorganize os valores dos três argumentos de modo que <code>a</code> &le; <code>b</code> &le; <code>c</code>. Os parâmetros são referências, então a função altera as variáveis de quem a chamou. Use comparações e trocas (pode usar <code>swap</code> da biblioteca padrão) em vez de colocar os valores em um vetor.</p><p>Os valores podem ser negativos e podem se repetir.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[void sort_three(int& a, int& b, int& c) {
    if (a > b) {
        swap(a, b);
    }
    if (b > c) {
        swap(b, c);
    }
    if (a > b) {
        swap(a, b);
    }
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[int a = 3, b = 1, c = 2;
sort_three(a, b, c);
cout << a << " " << b << " " << c << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 2 3]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[int a = 3, b = 2, c = 1;
sort_three(a, b, c);
cout << a << " " << b << " " << c << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 2 3]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[int a = 1, b = 2, c = 3;
sort_three(a, b, c);
cout << a << " " << b << " " << c << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 2 3]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[int a = 5, b = 5, c = 1;
sort_three(a, b, c);
cout << a << " " << b << " " << c << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 5 5]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[int a = -1, b = -3, c = -2;
sort_three(a, b, c);
cout << a << " " << b << " " << c << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[-3 -2 -1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[int a = 2, b = 3, c = 1;
sort_three(a, b, c);
cout << a << " " << b << " " << c << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 2 3]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>functions</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Área com sobrecarga]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Em C++, várias funções podem ter o mesmo nome, desde que as listas de parâmetros sejam diferentes; isso se chama sobrecarga. Escreva duas funções chamadas <code>area</code>:</p><ul><li><code>double area(double radius)</code> devolve a área de um círculo, &pi;<i>r</i>&sup2;;</li><li><code>double area(double width, double height)</code> devolve a área de um retângulo.</li></ul><p>Use &pi; com a precisão completa de <code>double</code> (por exemplo, <code>acos(-1.0)</code> ou 3.14159265358979), e não 3.14. Os argumentos são 0 ou positivos. Os testes imprimem os resultados com duas casas decimais.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[const double PI = acos(-1.0);

double area(double radius) {
    return PI * radius * radius;
}

double area(double width, double height) {
    return width * height;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout.precision(2); cout << fixed << area(1.0) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[3.14]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout.precision(2); cout << fixed << area(3.0, 4.0) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[12.00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout.precision(2); cout << fixed << area(10.0) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[314.16]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout.precision(2); cout << fixed << area(0.5) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0.79]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout.precision(2); cout << fixed << area(2.5, 0.4) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1.00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout.precision(2); cout << fixed << area(0.0) << " " << area(0.0, 7.5) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0.00 0.00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>functions</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Torre de Hanói]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>No quebra-cabeça da Torre de Hanói, <i>n</i> discos de tamanhos diferentes estão empilhados em um pino, com o maior embaixo. O objetivo é levar a pilha inteira para outro pino, movendo um disco por vez e sem nunca colocar um disco sobre outro menor; o terceiro pino serve de auxiliar.</p><p>Escreva uma função recursiva <code>void hanoi(int n, int from, int to, int via)</code> que imprima os movimentos da solução mais curta para levar <i>n</i> discos do pino <code>from</code> para o pino <code>to</code> usando o pino <code>via</code>. Imprima um movimento por linha, como dois números separados por um espaço: o pino de onde o disco sai e o pino para onde ele vai. Por exemplo, <code>hanoi(2, 1, 3, 2)</code> imprime:</p><pre>1 2
1 3
2 3</pre><p>Os pinos são numerados 1, 2 e 3, e 0 &le; <i>n</i> &le; 10. Para <i>n</i> = 0 nada é impresso.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[void hanoi(int n, int from, int to, int via) {
    if (n == 0) {
        return;
    }
    hanoi(n - 1, from, via, to);
    cout << from << " " << to << endl;
    hanoi(n - 1, via, to, from);
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[hanoi(1, 1, 3, 2)]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 3]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[hanoi(3, 1, 3, 2)]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 3
1 2
3 2
1 3
2 1
2 3
1 3]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[hanoi(2, 3, 1, 2)]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[3 2
3 1
2 1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[hanoi(0, 1, 3, 2); hanoi(1, 2, 1, 3)]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[2 1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[hanoi(4, 1, 2, 3)]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 3
1 2
3 2
1 3
2 1
2 3
1 3
1 2
3 2
3 1
2 1
3 2
1 3
1 2
3 2]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>recursion</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Inverter as palavras]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escreva um programa que leia uma linha e imprima as palavras dela em ordem inversa, separadas por um único espaço.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_program</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main() {
    string line, word;
    getline(cin, line);
    istringstream words(line);
    vector<string> all;
    while (words >> word) {
        all.push_back(word);
    }
    for (size_t i = all.size(); i > 0; i--) {
        cout << all[i - 1] << (i > 1 ? " " : "");
    }
    cout << endl;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[one two three
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[three two one]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[  spaced   out  words 
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[words out spaced]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[single
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[single]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[1 2 3 4 5
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[5 4 3 2 1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>strings</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Comprimir letras repetidas]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escreva uma função <code>string compress(const string&amp; s)</code> que substitua cada sequência de caracteres iguais e consecutivos de <code>s</code> pelo caractere seguido do tamanho da sequência. Por exemplo, <code>"aaabccdddd"</code> vira <code>"a3b1c2d4"</code>: toda sequência recebe seu número, mesmo uma sequência de um só caractere. Uma string vazia resulta em uma string vazia.</p><p><code>s</code> contém apenas letras, e maiúsculas e minúsculas são diferentes (<code>a</code> e <code>A</code> não são a mesma letra). Ela tem no máximo 1000 caracteres, então uma sequência pode ter mais de 9.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[string compress(const string& s) {
    string result;
    size_t i = 0;
    while (i < s.size()) {
        size_t j = i;
        while (j < s.size() && s[j] == s[i]) {
            j++;
        }
        result += s[i];
        result += to_string(j - i);
        i = j;
    }
    return result;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << compress("xxyzzz") << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[x2y1z3]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << compress("abc") << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[a1b1c1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << compress("aAAa") << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[a1A2a1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << "[" << compress("") << "]" << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[[]]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << compress("q") << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[q1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << compress(string(12, 'w') + "v") << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[w12v1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>strings</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Média de um vetor]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escreva uma função <code>double average(const vector&lt;int&gt;&amp; v)</code> que devolva a média dos números de <code>v</code>, ou 0 se <code>v</code> estiver vazio.</p><p>Os testes imprimem o resultado com <code>cout &lt;&lt;</code>, então 2.5 aparece como <code>2.5</code> e 3.0 como <code>3</code>.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[double average(const vector<int>& v) {
    if (v.empty()) {
        return 0;
    }
    long long sum = 0;
    for (int x : v) {
        sum += x;
    }
    return static_cast<double>(sum) / v.size();
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << average({1, 2, 3, 4}) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[2.5]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << average({}) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << average({1, 2}) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1.5]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << average({-3, 3, 9}) << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[3]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>lists</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Remover repetidos]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escreva uma função <code>vector&lt;int&gt; remove_duplicates(const vector&lt;int&gt;&amp; v)</code> que devolva um novo vetor com os valores de <code>v</code>, mantendo só a primeira ocorrência de cada valor, na ordem em que os valores aparecem pela primeira vez. Por exemplo, {3, 1, 3, 2, 1} resulta em {3, 1, 2}.</p><p><code>v</code> tem no máximo 1000 elementos e pode estar vazio. Não ordene: o resultado deve manter a ordem original.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[vector<int> remove_duplicates(const vector<int>& v) {
    vector<int> result;
    for (int x : v) {
        if (find(result.begin(), result.end(), x) == result.end()) {
            result.push_back(x);
        }
    }
    return result;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[for (int x : remove_duplicates({4, 2, 4, 4, 7, 2})) cout << x << " ";
cout << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[4 2 7]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[for (int x : remove_duplicates({1, 2, 3})) cout << x << " ";
cout << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 2 3]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[for (int x : remove_duplicates({5, 5, 5, 5})) cout << x << " ";
cout << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[5]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << remove_duplicates({}).size() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[for (int x : remove_duplicates({-1, 0, -1, 0, 2, 9, 2})) cout << x << " ";
cout << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[-1 0 2 9]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[for (int x : remove_duplicates({9, 8, 7, 8, 9})) cout << x << " ";
cout << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[9 8 7]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>lists</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Frequência de palavras]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escreva uma função <code>map&lt;string, int&gt; word_count(const string&amp; text)</code> que devolva quantas vezes cada palavra aparece em <code>text</code>. As palavras são separadas por um ou mais espaços, e maiúsculas e minúsculas importam: <code>Ana</code> e <code>ana</code> são palavras diferentes. Um texto vazio resulta em um mapa vazio.</p><p>O programa de teste não inclui <code>&lt;map&gt;</code>, então comece sua resposta com <code>#include &lt;map&gt;</code> e os outros cabeçalhos que usar (como <code>&lt;sstream&gt;</code>). Os testes imprimem todas as entradas do mapa na ordem do próprio <code>map</code>, que é a ordem crescente das chaves comparando os códigos dos caracteres (por isso maiúsculas vêm antes de minúsculas).</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>20</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[#include <map>
#include <sstream>

map<string, int> word_count(const string& text) {
    map<string, int> counts;
    istringstream words(text);
    string word;
    while (words >> word) {
        counts[word]++;
    }
    return counts;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[map<string, int> m = word_count("a b a c b a");
for (const auto& [word, n] : m) cout << word << " " << n << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[a 3
b 2
c 1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[map<string, int> m = word_count("  sol  mar sol ");
for (const auto& [word, n] : m) cout << word << " " << n << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[mar 1
sol 2]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << word_count("").size() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[cout << word_count("    ").size() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[map<string, int> m = word_count("ana Ana ana");
for (const auto& [word, n] : m) cout << word << " " << n << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[Ana 1
ana 2]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[map<string, int> m = word_count("1 22 1 333 22 1");
for (const auto& [word, n] : m) cout << word << " " << n << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 3
22 2
333 1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>maps</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Classe conta bancária]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escreva uma classe <code>Account</code> para uma conta bancária simples, com saldo em um número inteiro de unidades de dinheiro. Ela tem:</p><ul><li>um construtor <code>Account(int initial = 0)</code>, que abre a conta com saldo <code>initial</code> (0 ou mais);</li><li><code>void deposit(int amount)</code>, que soma <code>amount</code> ao saldo e não faz nada se <code>amount</code> for 0 ou negativo;</li><li><code>bool withdraw(int amount)</code>, que subtrai <code>amount</code> e devolve <code>true</code> somente se <code>amount</code> for positivo e não for maior que o saldo; caso contrário, não altera nada e devolve <code>false</code>;</li><li><code>int balance() const</code>, que devolve o saldo atual.</li></ul><p>Guarde o saldo em um membro <code>private</code>, para que a única forma de alterá-lo seja por <code>deposit</code> e <code>withdraw</code>. Os saldos ficam abaixo de 10<sup>9</sup>. Os testes imprimem os resultados <code>bool</code> como 1 ou 0.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>30</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[class Account {
public:
    Account(int initial = 0) : balance_(initial) {}

    void deposit(int amount) {
        if (amount > 0) {
            balance_ += amount;
        }
    }

    bool withdraw(int amount) {
        if (amount <= 0 || amount > balance_) {
            return false;
        }
        balance_ -= amount;
        return true;
    }

    int balance() const {
        return balance_;
    }

private:
    int balance_;
};
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Account a(100);
a.deposit(50);
cout << a.balance() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[150]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Account a(100);
bool ok = a.withdraw(30);
cout << ok << " " << a.balance() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 70]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Account a(100);
bool ok = a.withdraw(150);
cout << ok << " " << a.balance() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0 100]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Account a;
a.deposit(-20);
a.deposit(0);
cout << a.balance() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Account a(40);
bool ok1 = a.withdraw(40);
bool ok2 = a.withdraw(-5);
bool ok3 = a.withdraw(1);
cout << ok1 << " " << ok2 << " " << ok3 << " " << a.balance() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 0 0 0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Account a(10), b(20);
a.deposit(5);
b.withdraw(20);
cout << a.balance() << " " << b.balance() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[15 0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>classes</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Classe relógio]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escreva uma classe <code>Clock</code> que guarde uma hora do dia em um relógio de 24 horas. Ela tem:</p><ul><li>um construtor <code>Clock(int hours, int minutes)</code>, com 0 &le; <code>hours</code> &le; 23 e 0 &le; <code>minutes</code> &le; 59;</li><li><code>void add_minutes(int minutes)</code>, que adianta o relógio em <code>minutes</code> minutos, ou o atrasa se <code>minutes</code> for negativo, passando pela meia-noite quantas vezes for preciso (|<code>minutes</code>| &le; 10<sup>6</sup>);</li><li><code>string str() const</code>, que devolve a hora no formato <code>HH:MM</code>, com dois dígitos em cada parte (por exemplo, <code>09:05</code>).</li></ul><p>Dica: guardar a hora como o número de minutos desde a meia-noite deixa <code>add_minutes</code> curta.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>30</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[class Clock {
public:
    Clock(int hours, int minutes) : minutes_(hours * 60 + minutes) {}

    void add_minutes(int minutes) {
        // % can give a negative result, so add a day before taking it again.
        minutes_ = ((minutes_ + minutes) % 1440 + 1440) % 1440;
    }

    string str() const {
        return two_digits(minutes_ / 60) + ":" + two_digits(minutes_ % 60);
    }

private:
    int minutes_;  // minutes since midnight, from 0 to 1439

    static string two_digits(int x) {
        return (x < 10 ? "0" : "") + to_string(x);
    }
};
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Clock c(9, 5);
cout << c.str() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[09:05]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Clock c(23, 45);
c.add_minutes(30);
cout << c.str() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[00:15]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Clock c(0, 10);
c.add_minutes(-20);
cout << c.str() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[23:50]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Clock c(12, 0);
c.add_minutes(3 * 1440 + 61);
cout << c.str() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[13:01]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Clock c(5, 30);
c.add_minutes(-2 * 1440 - 31);
cout << c.str() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[04:59]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Clock a(10, 0), b(10, 0);
a.add_minutes(45);
a.add_minutes(-1000000);
cout << a.str() << " " << b.str() << endl]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[00:05 10:00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>cpp</text></tag>
      <tag><text>classes</text></tag>
    </tags>
  </question>
</quiz>
