Advertisement

C++-based triangle collection

阅读量:

C++输出各种样式的三角形

示例一(直角三角形符号)

复制代码
    #include <iostream>
    using namespace std;
     
    int main()
    {
    int rows;
     
    cout << "输入行数: ";
    cin >> rows;
     
    for(int i = 1; i <= rows; ++i)
    {
        for(int j = 1; j <= i; ++j)
        {
            cout << "* ";
        }
        cout << "\n";
    }
    return 0;
    }
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    

输出结果

复制代码
    * * * * * * * * * * * * * * *
    
    
      
      
      
      

全部评论 (0)

还没有任何评论哟~