Find Tons of C++ Programming examples, projects with code. Also find books solutions.
how to form such pattern use for loop1234567654321123456 65432112345 543211234 4321123 32112 211 1
#includeusing namespace std;/*1234567 7654321123456 65432112345 543211234 4321123 32112 211 1*/void main() { int n = 8; int p = n - 1; for (int i = n; i >= 0; i--) { for (int j = 1; j < i; j++) { cout << j; } cout << " "; for (int k = p; k > 0; k--) { cout << k; } p--; cout << endl; }}
how to print following shape? ***** * * * * * *****anyone??
Please give me the code in C++5 * * * ** 4 * * ** * 3 * ** * * 2 ** * * * 1
If we make a function call DrawBox(int h,int w) with h=5 and w=5, the following should print:******0*0*******0*0******
//FOR//5 * * * *//* 4 * * *//* * 3 * *//* * * 2 *//* * * * 1#include using namespace std;int main(){ int i, j, r = 5; for (i = 1; i <= 5; i++) { for (j = 1; j <= 5; j++) { if (i == j) { cout << r; r = r - 1; } else { cout << "*"; } } cout << endl; } return 0;}
**** ** *******how to make that code
* * * * ***************how to make that code
+------+| ^^ || ^ ^ ||^ ^|| ^^ || ^ ^ ||^ ^|+------+|v v|| v v || vv ||v v|| v v || vv |+------+how to print this
+------+| ^^ || ^ ^ ||^ ^|| ^^ || ^ ^ ||^ ^|+------+|v v|| v v || vv ||v v|| v v || vv |+------+how to print this.
Post a Comment
11 Questions:
how to form such pattern use for loop
1234567654321
123456 654321
12345 54321
1234 4321
123 321
12 21
1 1
#include
using namespace std;
/*
1234567 7654321
123456 654321
12345 54321
1234 4321
123 321
12 21
1 1
*/
void main() {
int n = 8;
int p = n - 1;
for (int i = n; i >= 0; i--) {
for (int j = 1; j < i; j++) {
cout << j;
}
cout << " ";
for (int k = p; k > 0; k--) {
cout << k;
}
p--;
cout << endl;
}
}
how to print following shape?
*****
* *
*
* *
*****
anyone??
Please give me the code in C++
5 * * * *
* 4 * * *
* * 3 * *
* * * 2 *
* * * * 1
If we make a function call DrawBox(int h,int w) with h=5 and w=5, the following should print:
*****
*0*0*
*****
*0*0*
*****
If we make a function call DrawBox(int h,int w) with h=5 and w=5, the following should print:
*****
*0*0*
*****
*0*0*
*****
//FOR
//5 * * * *
//* 4 * * *
//* * 3 * *
//* * * 2 *
//* * * * 1
#include
using namespace std;
int main()
{
int i, j, r = 5;
for (i = 1; i <= 5; i++)
{
for (j = 1; j <= 5; j++)
{
if (i == j)
{
cout << r;
r = r - 1;
}
else
{
cout << "*";
}
}
cout << endl;
}
return 0;
}
*
**
* *
* *
******
how to make that code
*
* *
* *
**************
how to make that code
+------+
| ^^ |
| ^ ^ |
|^ ^|
| ^^ |
| ^ ^ |
|^ ^|
+------+
|v v|
| v v |
| vv |
|v v|
| v v |
| vv |
+------+
how to print this
+------+
| ^^ |
| ^ ^ |
|^ ^|
| ^^ |
| ^ ^ |
|^ ^|
+------+
|v v|
| v v |
| vv |
|v v|
| v v |
| vv |
+------+
how to print this.
Post a Comment