How do I make this work for even number of rows?
#include
using namespace std;
int main() {
int n,k,c;
cin >> n;
c = ((n+1)/2)-1;
k = ((n+1)/2)+1;
for(int i = 1; i <= n; i++)
{
if(i <= (n+1)/2)
{
--k;
++c;
}
else
{
++k;
--c;
}
for(int j = 1; j <= n; j++)
{
if(j <= k || j >= c)
cout << "*";
else
cout << " ";
}
cout << endl;
}
return 0;
}