Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- using namespace std;
- vector<int> findOdd(int start, int end) {
- vector<int> a{0};
- for(int i=start; i<end; i++) {
- if(i % 2 != 0) a.push_back(i);
- }
- return a;
- }
- int main() {
- cout << "Enter height: ";
- int h;
- cin >> h;
- vector<int> z = findOdd(0, (h*2)-1);
- for(int i=0; i<h; i++) {
- cout << string(h-i-1, ' ') << i+1 << string(z[i], '0') << (i+1 != 1 ? to_string(i+1) : "") << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement