Guest User

Untitled

a guest
Dec 14th, 2019
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. using namespace std;
  5.  
  6. vector<int> findOdd(int start, int end) {
  7.     vector<int> a{0};
  8.     for(int i=start; i<end; i++) {
  9.         if(i % 2 != 0) a.push_back(i);
  10.     }
  11.     return a;
  12. }
  13.  
  14. int main() {
  15.     cout << "Enter height: ";
  16.     int h;
  17.     cin >> h;
  18.  
  19.     vector<int> z = findOdd(0, (h*2)-1);
  20.     for(int i=0; i<h; i++) {
  21.         cout << string(h-i-1, ' ') << i+1 << string(z[i], '0') << (i+1 != 1 ? to_string(i+1) : "") << endl;
  22.     }
  23.    
  24.     return 0;
  25. }
RAW Paste Data