打印重复数字模式
Print repeating digit pattern
如何显示连续数字的重复模式?
这就是我希望实现的目标:
1 12 ... 123456789 1234567890 12345678901
这是我的代码:
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int i,j,rows;
cout << "Enter the number of rows: ";
cin >> rows;
for(i=1;i<=rows;++i)
{
for(j=1;j<=i;++j)
{
cout << j << " ";
}
cout << endl;
}
getch();
return 0;
}
这不会重复字符。如何让它在 9 后重复?
使用模运算符。
std::cout << (j % 10) << ' ';
相关文章:
- 比较并显示使用最小值(a,b)和最大值(a、b)升序排列的4个数字
- 在C++的一系列数字中查找重复模式
- 正则表达式以匹配数字的重复模式,后跟任何类型的分隔符?
- 在此任务上遇到麻烦,我们需要使用指针和数组来找到文本文件中某些数字的平均值,中值和模式
- 编写模式识别'函数以查找特定顺序出现的数字?C++
- 从列表到数组C 查找模式或最常见的数字
- 在x86_64模式下,64 位数字不适合寄存器整数
- 通过2D阵列C 移动锯齿ZAG模式的数字
- 为什么 std::setprecision(6) 在固定宽度模式式传输超过 6 位数字
- c++rand()和来自boost的RNG生成相同的数字(在发布模式中),即使srand(0)也是如此
- 打印重复数字模式
- 如何在C++中生成具有奇怪模式的数字
- 无模式例外是什么意思?(数组中出现次数最多的数字)
- 查找 n 个数字的模式
- 嵌套循环:数字模式
- 以二进制模式扫描文件,并将十六进制字符解释为C++中的实际数字
- 使用递归的c++数字模式函数
- 创建一个数字模式
- 是否可以在CEdit控件的纯数字和字母数字输入模式之间切换
- 如何在C++中显示此数字模式