c ++ 打印字符串
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr(); //to clear the screen
int i,j,k,n;
cout<<“How many lines?”;
cin>>n;
for(i=0;i<n;++i)
{
cout<<“n”;
for(j=0;j<i;++j)
cout<<” “;
for(k=n;k>i;–k)
cout<<“*”;
}
getch(); //to stop the screen
}
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr(); //to clear the screen
int i,j,k,n;
cout<<“How many lines?”;
cin>>n;
for(i=0;i<n;++i)
{
cout<<“n”;
for(j=0;j<i;++j)
cout<<” “;
for(k=n;k>i;–k)
cout<<“*”;
}
getch(); //to stop the screen
}
翻译自: https://www.thecrazyprogrammer.com/2012/07/c-program-to-print-following-trianlge.html
c ++ 打印字符串