Exemplo n.º 1
0
/*
 * Converts stat num into a six-char (right justified) string
 */
QString cnv_stat(int val)
{
    QString str;

    /* Above 18 */
    if (val > 18)
    {
        int bonus = (val - 18);

        if (game_mode == GAME_NPPMORIA)
        {
            if (bonus > 99) bonus = 100;
        }

        if (bonus >= 220)
            str = "18/***";
        else if (bonus >= 100)
            str = QString("18/%1").arg(_num(bonus), 3, '0');
        else
            str = QString(" 18/%1").arg(_num(bonus), 2, '0');
    }

    /* From 3 to 18 */
    else
    {
        str = QString("%1").arg(_num(val), 6, ' ');
    }

    return str;
}
Exemplo n.º 2
0
Arquivo: led.c Projeto: akkana/arduino
static uint8_t
_char (char c)
{
    return (c >= '0' && c <= '9') ? _num (c - '0')
         : (c >= 'a' && c <= 'f') ? _num (c - 'a' + 10)
         : (c >= 'A' && c <= 'F') ? _num (c - 'A' + 10)
         : (c == '-') ? charset [16]
         : 0; /* blank */
}
Exemplo n.º 3
0
 vector<vector<int> > threeSum(vector<int> &num) {
     vector<int> _num(num);
     vector<vector<int>> res;
     sort(_num.begin(), _num.end());
     for (int i = 0; i < _num.size(); ++i) {
         if (i != 0 && _num[i] == _num[i - 1]) continue;
         
         int j = i + 1;
         int k = _num.size() - 1;
         while (j < k) {
             int sum = _num[i] + _num[j] + _num[k];
             if (sum == 0) {
                 vector<int> tmp;
                 tmp.push_back(_num[i]);
                 tmp.push_back(_num[j]);
                 tmp.push_back(_num[k]);
                 res.push_back(tmp);
                 ++j;
                 --k;
                 while (j < k && _num[j] == _num[j - 1]) ++j;
                 while (j < k && _num[k] == _num[k + 1]) --k;
             }
             else if (sum > 0) --k;
             else ++j;
         }
         
     }
     return res;
 }
static int _clk_id(pwm_t dev)
{
    if (_num(dev) == 2) {
        return TCC2_GCLK_ID;
    }
    return TCC0_GCLK_ID;
}
static void poweron(pwm_t dev)
{
    PM->APBCMASK.reg |= (PM_APBCMASK_TCC0 << _num(dev));
    GCLK->CLKCTRL.reg = (GCLK_CLKCTRL_CLKEN |
                         GCLK_CLKCTRL_GEN_GCLK0 |
                         GCLK_CLKCTRL_ID(_clk_id(dev)));
    while (GCLK->STATUS.bit.SYNCBUSY) {}
}
void pwm_poweroff(pwm_t dev)
{
    _tcc(dev)->CTRLA.reg &= ~(TCC_CTRLA_ENABLE);

    PM->APBCMASK.reg &= ~(PM_APBCMASK_TCC0 << _num(dev));
    GCLK->CLKCTRL.reg = (GCLK_CLKCTRL_GEN_GCLK7 |
                         GCLK_CLKCTRL_ID(_clk_id(dev)));
    while (GCLK->STATUS.bit.SYNCBUSY) {}
}