从个位开始计数,然后是十位,以此类推
Count bits starting from the ones, then tens and so on
用c++编程
我正试图以字符串的形式从二进制代码中只打印出指定的数字。用户可以指定某个数字位置,并且必须打印该位置上的数字。
。字符串c = "11011001",用户想要第一个位置。输出必须为0。
计数索引从0开始,从"个位"开始,这意味着请求的第一个位置是"十位"位置上的数字。
我不知道如何从一列开始计数。我试过c.at(),但它从最左边的数字开始,向右计数。
你可以这样做:
#include <iostream>
#include <string>
int main ()
{
std::string str ("11011001");
int postion = 1;
std::cout << str[str.length()-position];
}
相关文章:
- 在视觉工作室中以十六进制进行位移位并通过 cout 输出
- 如何处理高于 7FF.. 64 位和uint64_t类型的十六进制值
- 按位函数 AND、OR 和 XOR 在 C++ 中使用十六进制字符串
- 我如何在GDB中打印十六进制的双重位
- C - 十六进制中的反向位
- 我如何使用十一位数字
- 如何将整数向量转换为 2 位十六进制并按顺序添加到 c 字符串?
- 用IO操纵器在十六进制中打印一个8位号码
- 从 bin 文件 -c++ 中读取十六进制数字为每个字符 2 位数字
- 将十进制的舍入到第十位,但在C 中显示了百分之一
- 使用位操作员将十进制转换为八十位
- 将每 4 位解释为十六进制值
- 反转十六进制字符串C++的第 7 位
- 我可以将指针地址(即十六进制整数)转换为C 中的十进制和八分位基础
- 如何获取十六进制数的最后 n 位数字
- 如何在C++中将十六进制转换为IEEE 754 32位浮点
- fortran 64位十六进制BOZ
- 将二进制值转换为十六进制值(32位)
- C++ 中的十六进制按位运算
- 从个位开始计数,然后是十位,以此类推