-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3rd_patterns.cpp
More file actions
176 lines (156 loc) · 2.75 KB
/
Copy path3rd_patterns.cpp
File metadata and controls
176 lines (156 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#include <iostream>
using namespace std;
int main(){
int n = 4;
for(int i = 1; i<= n;i++){ //coloums
for(int i = 1; i<=n;i++){
cout << i; //for rows
}
cout << endl;
}
cout << endl;
// print abcd
int n2 = 4;
for(int i = 0;i< n2;i++){
char ch = 'A';
for(int i = 0;i<n2;i++){
cout << ch;
ch += 1;
}
cout << endl;
}
cout << endl;
//print number
int n3 = 3;
int num = 1;
for (int i=0;i<n3;i++){
for(int i = 1;i<=n3;i++){
cout << num ;
num++;
}
cout << endl;
}
cout << endl;
// abcd
int b= 3;
char c = 'A';
for(int i = 0;i<b;i++){
for(int i = 0;i<b;i++){
cout << c;
c += 1;
}
cout << endl;
}
// Tringle Pattern
int a = 4;
for(int i = 0;i<a;i++){ //rows
for(int j =0;j<i+1;j++){ // coloums
cout << "*";
}
cout << endl;
}
int n4 = 4;
for(int i = 0; i < n4;i++){
for(int j =0;j < i+1;j++){
cout << (i+1);
}
cout << endl;
}
int n5 =4;
for(int i =0; i< n5;i++){
for(int j= 1;j< i+1;j++){
cout << j;
}
cout << endl;
}
int n6 = 6;
for(int i = 0; i<n6 ;i++){
for(int j =i-1;j>0;j--){
cout << j;
}
cout << endl;
}
int n7 = 4;
int num2 =1;
for(int i = 0; i< n7;i++){
for(int j = 0;j< i+1;j++){
cout << num2;
num2++;
}
cout << endl;
}
cout << endl;
int n8 = 4;
char ch = 'A';
for(int i = 0;i< n8;i++){
for(int j = 0;j < i+1;j++){
cout << ch;
ch++;
}
cout << endl;
}
int n9 = 4;
int num3 = 1;
for(int i =0;i<n9;i++){
//space
for(int j=0;j<i;j++){
cout << " ";
}
for(int j= 0;j<n9-1;j++){
cout << (i+1);
}
cout << endl;
}
// for pyramid
int s = 9;
for(int i = 0; i< s;i++){
// spaces : n-i-1
for(int j = 0;j < s-i-1;j++){
cout << " ";
}
// nums1 : i+1
for(int j=1;j<=i+1;j++){
cout << j;
}
// num2
for(int j=i;j>0;j--){
cout << j;
}
cout << endl;
}
// hollow diamond pattern
int m =4;
// top
for(int i=0; i<m;i++){
//space
for(int j=0; j<m-i-1 ; j++){
cout << " ";
}
cout <<"*";
if(i != 0){
//space
for(int j=0;j<2*i-1;j++){
cout << " ";
}
cout << "*";
}
cout << endl;
}
// bottom
for(int i =0;i<m-1;i++){
//space
for(int j=0;j<i+1;j++){
cout << " ";
}
cout << "*";
if(i != m-2){
//space
for(int j=0;j<2*(m-i)-5;j++){
cout << " ";
}
cout << "*";
}
cout << endl;
}
return 0;
}