C++ Programs on various Tree Problems
Printing Reverse Rectangle using numbers
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
Solution:-
#include
using namespace std;
int main(int argc, char *argv[]) {
int count = 5;
int i,j,k;
for(i = 0 ; i<5; i++)
{
for(j=0; j0; k-- )
cout<
Printing Triangle Pattern using numbers
1
1 2
1 2 3
1 2
1
Solution:-
#include
using namespace std;
int main(int argc, char *argv[]) {
int count = 0;
int i,j;
int rows = 5;
for(i = 0 ; i
Printing Rectangle one on Another Pattern using numbers
1 2 3
1 2
1
1 2
1 2 3
Solution:-
#include
using namespace std;
int main(int argc, char *argv[]) {
int count = 0;
int i,j;
int rows = 5;
count = rows/2 +1;
for(i = 0 ; i
Printing two Rectangle Pattern using numbers
1 2 3 4 5 4 3 2 1
1 2 3 4 4 3 2 1
1 2 3 3 2 1
1 2 2 1
1 1
Solution:-
#include
using namespace std;
int main(int argc, char *argv[]) {
int count = 0;
int i,j;
int rows = 5;
int temp = rows;
count = rows/2 +1;
for(i = 0 ; i=1;j--)
cout<