Printing "K"
Problem:
Print "K" on the console.
Solution:
# include <iostream>
# include <iomanip>
using namespace std;
int main()
{
int s1, n, n1;
cin >> n;
n1 = n;
s1 = 0;
for (int i = 0; i < (n / 2); i++)
{
while (i < n / 2)
{
cout <<"*"<< setw(n1 - 1) << "*";
n1 = n1 - 2;
i++;
cout << endl;
}
}
for (int i = 0; i < (n / 2); i++)
{
while (i < n / 2)
{
cout <<"*"<< setw(n1 +1) << "*";
n1 = n1 +2;
i++;
cout << endl;
}
}
return 0;
}
Print "K" on the console.
Solution:
# include <iostream>
# include <iomanip>
using namespace std;
int main()
{
int s1, n, n1;
cin >> n;
n1 = n;
s1 = 0;
for (int i = 0; i < (n / 2); i++)
{
while (i < n / 2)
{
cout <<"*"<< setw(n1 - 1) << "*";
n1 = n1 - 2;
i++;
cout << endl;
}
}
for (int i = 0; i < (n / 2); i++)
{
while (i < n / 2)
{
cout <<"*"<< setw(n1 +1) << "*";
n1 = n1 +2;
i++;
cout << endl;
}
}
return 0;
}