输出*号组成的菱形:

C++ 输出菱形

// print.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    int N = 15;
    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= N - i; j++)
        {
            cout << " ";
        }
        for (int k = 1; k <= i; k++)
        {
            cout << "* ";
        }
        cout << endl;
    }
    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= i; j++)
        {
            cout << " ";
        }
        for (int k = 1; k <= N - i; k++)
        {
            cout << "* ";
        }
        cout << endl;
    }
    return 0;
}

相关文章:

  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
猜你喜欢
  • 2021-08-02
  • 2021-05-19
  • 2022-12-23
  • 2021-09-16
  • 2021-07-23
相关资源
相似解决方案