-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
588 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"files.associations": { | ||
"iostream": "cpp", | ||
"ostream": "cpp" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* * * * | ||
* * * * | ||
* * * * | ||
* * * * | ||
* * * * | ||
Rows 5 | ||
Cols 4 | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int rows = 5, cols = 4; | ||
int i, j; | ||
for (i = 0; i < rows; ++i) | ||
{ | ||
for (j = 0; j < cols; ++j) | ||
{ | ||
cout << "* "; | ||
} | ||
cout << endl; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* * * * | ||
* * * * | ||
* * * * | ||
* * * * | ||
* * * * | ||
n 5 | ||
rows 1 to n | ||
cols | ||
n-i = spaces at first {space print from 1 to n-i} | ||
then print starts 1 to n | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int n = 5; | ||
int i, j; | ||
for (i = 0; i < n; ++i) | ||
{ | ||
for (j = 0; j < n - i; ++j) | ||
{ | ||
cout << " "; | ||
} | ||
for (j = 0; j < n; ++j) | ||
{ | ||
cout << "* "; | ||
} | ||
cout << endl; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
1 | ||
1 2 | ||
1 2 3 | ||
1 2 3 4 | ||
1 2 3 4 5 | ||
n=5 | ||
Rows i to n (i ptr) | ||
space will be n-i | ||
cols 1 to i numbers | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int n = 5; | ||
int i, j; | ||
int cnt = 0; | ||
for (i = 1; i <= n; ++i) //for rows | ||
{ | ||
for (j = 1; j <= n; ++j) //for cols | ||
|
||
{ | ||
|
||
if (j <= n - i) | ||
{ | ||
cout << " "; | ||
} | ||
else | ||
{ | ||
cout << ++cnt << " "; | ||
} | ||
} | ||
cnt = 0; | ||
cout << endl; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
1 | ||
2 1 2 | ||
3 2 1 2 3 | ||
4 3 2 1 2 3 4 | ||
5 4 3 2 1 2 3 4 5 | ||
n=5 | ||
Rows 1 to n (i ptr) | ||
cols has 3 parts | ||
space -> 1 to n-i, when n =5 and row npo is 1 we have 4 spaces | ||
nos in decreasing order n-i to 1 -> k= row number (i), print k-- till 1 | ||
nos in incre order -> let k = 2 , k++ till n | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int n = 5; | ||
int i, j; | ||
for (i = 1; i <= n; i++) //for rows | ||
{ | ||
for (j = 1; j <= n - i; j++) //space -> 1 to n-i, when n =5 and row npo is 1 we have 4 spaces | ||
|
||
{ | ||
cout << " "; | ||
} | ||
int k = i; //nos in decreasing order n-i to n -> k= row number (i), print k-- till 1 | ||
for (; j <= n; j++) // j=n-i that is 4 to 5(n) (k is 1) | ||
{ | ||
cout << k-- << " "; | ||
} | ||
k = 2; //nos in incre order -> let k = 2 , k++ till | ||
for (; j <= n + i - 1; j++) //writing in terms of rows | ||
{ | ||
cout << k++ << " "; | ||
} | ||
cout << endl; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* | ||
* * * | ||
* * * * * | ||
* * * * * * * | ||
* * * * * * * | ||
* * * * * | ||
* * * | ||
* | ||
* | ||
* * * | ||
* * * * * | ||
* * * * * * * | ||
rows 1 to n | ||
cols | ||
spaces n-i | ||
stars 2*i - 1 will give stars will give me odd nos | ||
n=4 | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int n = 4; | ||
int i, j; | ||
int cnt = 0; | ||
//for first half | ||
for (i = 1; i <= n; ++i) //for rows | ||
{ | ||
|
||
for (j = 1; j <= n - i; ++j) //for spaces | ||
|
||
{ | ||
cout << " "; | ||
} | ||
for (j = 1; j <= (2 * i) - 1; ++j) //for stars (2*i - 1 will give stars will give me odd nos) | ||
|
||
{ | ||
|
||
cout << "* "; | ||
} | ||
cout << endl; | ||
} | ||
//for 2nd half | ||
for (i = n; i >= 1; --i) //for rows | ||
{ | ||
|
||
for (j = 1; j <= n - i; ++j) //for spaces | ||
|
||
{ | ||
cout << " "; | ||
} | ||
for (j = 1; j <= (2 * i) - 1; ++j) //for stars (2*i - 1 will give stars will give me odd nos) | ||
|
||
{ | ||
|
||
cout << "* "; | ||
} | ||
cout << endl; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* * | ||
* * * * | ||
* * * | ||
n=9 | ||
rows = 3 | ||
cols | ||
chech col and row no of stars | ||
when we add i+j we get 4,6,8,10,12 | ||
so i+j%4==0 will be acceptable for 4 and 8 and 12 | ||
but for 6 and 10 | ||
when i = 2 and j%4==0 | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int n = 9; | ||
int i, j; | ||
for (i = 1; i <= 3; ++i) //for rows | ||
{ | ||
for (j = 1; j <= n; ++j) //for cols | ||
|
||
{ | ||
if ((j + i) % 4 == 0 or (i == 2 and j % 4 == 0)) | ||
{ | ||
cout << "* "; | ||
} | ||
else | ||
{ | ||
cout << " "; | ||
} | ||
} | ||
cout << endl; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* * * * | ||
* * | ||
* * | ||
* * | ||
* * * * | ||
Rows 5 | ||
Cols 4 | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int rows = 5, cols = 4; | ||
int i, j; | ||
for (i = 0; i < rows; ++i) | ||
{ | ||
for (j = 0; j < cols; ++j) | ||
{ | ||
if (i == 0 or i == rows - 1) //when 1st row or last row | ||
{ | ||
cout << "* "; | ||
} | ||
else if (j == 0 or j == cols - 1) //when 1st column or last column | ||
{ | ||
cout << "* "; | ||
} | ||
else | ||
{ | ||
cout << " "; | ||
} | ||
} | ||
cout << endl; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* * * * * n=5 | ||
* * * * 4 | ||
* * * . | ||
* * . | ||
* 1 | ||
Rows 5 | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int n = 5; | ||
int i, j; | ||
for (i = n; i > 0; --i) //for rows | ||
{ | ||
for (j = 0; j < i; ++j) //for cols | ||
{ | ||
cout << "* "; | ||
} | ||
cout << endl; | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.