123456789
1 22 3** 4444 5**** 666666 7****** 88888888 9********
1234567891011121314151617181920212223242526
#include <iostream> int main() { int number; std::cout << "Enter a maximum number: "; std::cin >> number; for (int i = 0 ; i <= number ; i++){ if (i%2 == 0){ for (int j = 0 ; j < i ; j++){ std::cout << i; } } else { std::cout << i; for (int j = 0 ; j < (i - 1) ; j++){ std::cout << "*"; } } std::cout << "\n"; } return 0; }
123456789101112131415161718192021222324252627
#include <iostream> int main() { int number; std::cout << "Enter a maximum number: "; std::cin >> number; for (int i = 0 ; i <= number ; i++){ if (i%2){ std::cout << i; for (int j = 0 ; j < (i - 1) ; j++){ std::cout << "*"; } } else{ for (int j = 0 ; j < i ; j++){ std::cout << i; } } std::cout << "\n"; } return 0; }