解题思路:
1.创建变量a,b a=1,b=1
2.用for循环循环到循环次数大于等于a
3.嵌套在里面的for循环循环到循环次数大于等于b
#include<bits/stdc++.h>
using namespace std;
int main()
{
for(int a=1;a<=9;a++)
{
for(int b=1;b<=a;b++)
{
cout<<"*";
}
cout<<endl;
}
return 0;
}
解题思路:
1.创建变量a,b a=1,b=1
2.用for循环循环到循环次数大于等于a
3.嵌套在里面的for循环循环到循环次数大于等于b
#include<bits/stdc++.h>
using namespace std;
int main()
{
for(int a=1;a<=9;a++)
{
for(int b=1;b<=a;b++)
{
cout<<"*";
}
cout<<endl;
}
return 0;
}