Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n;
- void rec(int x) {
- if(x == 1) {
- for(int i = 0; i < n; i++) {
- cout << "*";
- }
- cout << endl;
- return;
- }
- if(x == n) {
- for(int i = 0; i < n; i++) {
- cout << "*";
- }
- cout << endl;
- }
- else {
- for(int i = 0; i < n; i++) {
- if(i == x - 1 or i == n - x) {
- cout << "*";
- }
- else {
- cout << " ";
- }
- }
- cout << endl;
- }
- rec(x - 1);
- }
- int main(){
- cin >> n;
- rec(n);
- return 0;
- }
- /*
- n = 7
- 0 *******
- 1 * *
- 2 * *
- 3 *
- 4 * *
- 5 * *
- 6 *******
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement