C++题目输出三角形

来源:百度知道 编辑:UC知道 时间:2024/09/22 08:25:19
a
b b
c c c
d d d d
e e e e e
f f f f f f
g g g g g g g

#include<iostream>
using namespace std;
int main()
{
int i,j;
for(i=1;i<=7;i++)
{
j=i;
while(j--)
{
cout<<char(i+'a'-1)<<" ";
}
cout<<endl;
}
return 0;
}

自己想
不是很难!