令牌桶算法+redis_C ++编程中的替代令牌

令牌桶算法+redis

Alternative Tokens in C++ are the set of special symbols and words that are used to represent some of the operators and punctuators.

C ++中的替代令牌是一组特殊的符号和单词,用于表示某些运算符和标点符号。

Following are the alternative tokens,

以下是替代令牌,

AlternativePrimary
<%{
%>}
<:> [
:>]
%:#
%:%:##
and&&
bitor|
or||
xor^
compl~
bitand&
and_eq&=
or_eq|=
xor_eq^=
not!
not_eq!=
另类
<% {
%> }
<:> [
:> ]
%:
%:%: ##
&&
咬人 |
要么 ||
异或 ^
补全
and
and_eq &=
or_eq | =
xor_eq ^ =
not_eq !=

Syntax:

句法:

%:define

Becomes,
#define

替代令牌的C ++程序 (C++ program of alternative tokens)

Example 1:

范例1:

// C++ program to demonstrate the example 
// of alternative tokens

# include <iostream>
using namespace std;

%:define MSG "Hello, world!"
%:define COUNTRY "INDIA"

int main()
<%
    cout << "My message is: " << MSG << endl;
    cout << "My country is: " << COUNTRY << endl;
    
    return 0;
%>

Output:

输出:

My message is: Hello, world!
My country is: INDIA

Example 2:

范例2:

/*
C++ example to demonstrate the use of
alternative operator keywords
*/

#include <iostream>
#include <bitset>
using namespace std;

int main()
{
    int a = 10;
    bitset<4> value("1111");
    bitset<4> mask1("1010");

    // and, or, not, not_eq keywords
    cout << "a: " << a << endl;
    cout << "(a>5 and a<20): " << (a > 5 and a < 20) << endl;
    cout << "(a>5 or a<20): " << (a > 5 or a < 20) << endl;
    cout << "not(a>5 and a<20): " << not(a > 5 and a < 20) << endl;
    cout << "(a not_eq 5): " << (a not_eq 5) << endl;

    //bitand, bitor, compl, and_eq, or_eq
    //xor, xor_eq keywords
    cout << "value: " << value << endl;
    cout << "mask1: " << mask1 << endl;
    cout << "(value bitand mask1): " << (value bitand mask1) << endl;
    cout << "(value bitor mask1): " << (value bitor mask1) << endl;
    cout << "(value xor mask1): " << (value xor mask1) << endl;
    cout << "compl value: " << compl value << endl;
    value and_eq mask1;
    cout << "value and_eq mask1: " << value << endl;
    value or_eq mask1;
    cout << "value or_eq mask1: " << value << endl;
    value xor_eq mask1;
    cout << "value xor_eq mask1: " << value << endl;
 
    return 0;
}

Output

输出量

a: 10
(a>5 and a<20): 1
(a>5 or a<20): 1
not(a>5 and a<20): 0
(a not_eq 5): 1
value: 1111
mask1: 1010
(value bitand mask1): 1010
(value bitor mask1): 1111
(value xor mask1): 0101
compl value: 0000
value and_eq mask1: 1010
value or_eq mask1: 1010
value xor_eq mask1: 0000


翻译自: https://www.includehelp.com/cpp-tutorial/alternative-tokens.aspx

令牌桶算法+redis

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值