fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void numpat(int n)
  5. {
  6.  
  7. int num = 1;
  8.  
  9. for (int i = 0; i < n; i++) {
  10.  
  11. for (int j = 0; j <= i; j++)
  12. cout << num << " ";
  13.  
  14. num = num + 1;
  15.  
  16. cout << endl;
  17. }
  18. }
  19.  
  20. int main()
  21. {
  22. int n = 5;
  23.  
  24. numpat(n);
  25. return 0;
  26. }
  27.  
  28.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
1 
2 2 
3 3 3 
4 4 4 4 
5 5 5 5 5