#include <iostream> using namespace std; void numpat(int n) { int num = 1; for (int i = 0; i < n; i++) { for (int j = 0; j <= i; j++) cout << num << " "; num = num + 1; cout << endl; } } int main() { int n = 5; numpat(n); return 0; }
Standard input is empty
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!