roberthsu2003 / cAndC-

51 stars 18 forks source link

作業2 #10

Closed roberthsu2003 closed 9 months ago

roberthsu2003 commented 9 months ago

利用2層for迴圈列印「井」字,將其排列成直角三角形

#
##
###
####
#####
a3137418 commented 9 months ago
#include <iostream>
using namespace std;
int main() {
  //巢狀迴圈
   for (int i = 1; i < 10; i++) {
    for (int j = 1; j < i; j++) {
      cout << "#" ;
    }
    cout << endl;
  }
}
FangYu0113 commented 9 months ago
#include <iostream>

using namespace std;

int main()
{
    for(int i=1;i<=5;i++)
    {
        for(int j=1;j<=i;j++)
        {
           cout<<"#"; 
        }
        cout<<endl;
    }
    return 0;
}
FatAnt93 commented 9 months ago
#include <iostream>
using namespace std;
int main()
{
    for(int i=0;i<5;i++)
    {
        for(int j=0;j<=i;j++)
        {
            cout << "#";
        }
        cout << endl;
    }
    return 0;
}