Half Diamond Using Number.
#include <iostream>
using namespace std;
int main()
{
int bad, count = 0, count_1 = 0, P = 0;
cout << "Enter Row's Number = ";
cin >> bad;
for (int i = 1; i
<= bad; ++i)
{
for (int spa = 1;
spa <= bad - i; ++spa)
{
cout << " ";
++count;
}
while (P != 2 * i - 1)
{
if (count <= bad - 1)
{
cout << i + P << " ";
++count;
}
else
{
++count_1;
cout << i + P - 2 * count_1 << " ";
}
++P;
}
count_1 = count = P = 0;
cout << endl;
}
system("pause");
}
Comments
Post a Comment