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