🔒 Closed Pa help po sa pattern mga sir

Status
Not open for further replies.

EEEEERRRRRAAAA

Honorary Poster
1623999285918.webp
 

c++ Code:

C++:
#include <iostream>
using namespace std;
int main(void) {
    for(int i=1; i<=5; i++){//do print each rows
        for(int j=i; j<=5; j++){ //print space for pyramid
        cout<<" ";
    }
    for(int k=1; k<2*i; k++){
            if(i==5 || (k==1 || k==2*i-1)){
                cout<<"&";
            }
            else{
                cout<<" ";
            }
    }
    cout<<"\n"; //move to next line
    }
}

Output:

1624000216249.webp
 

Compiler: Devcpp​

c++ Code:​

C++:
#include <iostream>
using namespace std;
int main(void) {
    for(int i=1; i<=5; i++){//do print each rows
        for(int j=i; j<=5; j++){ //print space for pyramid
        cout<<"  ";
    }
    for(int k=1; k<2*i; k++){
            if(i==5 || (k==1 || k==2*i-1)){
                cout<<"& ";
            }
            else{
                cout<<"  ";
            }
    }
    cout<<"\n"; //move to next line
    }
}

Output:

1624003030540.webp
 
Status
Not open for further replies.

About this Thread

  • 11
    Replies
  • 452
    Views
  • 4
    Participants
Last reply from:
Wakaka007

Trending Topics

Online now

Members online
1,065
Guests online
849
Total visitors
1,914

Forum statistics

Threads
2,274,946
Posts
28,959,527
Members
1,233,492
Latest member
PHC-Francis
Back
Top