Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main(void) {
- int i, j, k, s, no;
- char sym = '#';
- no = 11; // pattern width = odd
- s = (no /2) +1; // mid-point
- string st;
- for (i=1; i<s; ++i) st.push_back(' ');
- int p = s-1;
- for (i=1; i<s; ++i) {
- cout << st << sym; reverse(st.begin(), st.end());
- cout << st << endl; reverse(st.begin(), st.end());
- --p;
- st[p] = sym;
- }
- cout << st << sym; reverse(st.begin(), st.end());
- cout << st << endl; reverse(st.begin(), st.end());
- --p;
- for (i=1; i<s; ++i) {
- cout << st << sym; reverse(st.begin(), st.end());
- cout << st << endl; reverse(st.begin(), st.end());
- ++p;
- st[p] = ' ';
- }
- cout << st << sym; reverse(st.begin(), st.end());
- cout << st << endl; reverse(st.begin(), st.end());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement