欢迎DaLao指导

博客名称

你的一句话介绍

C++ 输出菱形

 

输出*号组成的菱形:

image

// 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;
}
posted @ 2014-11-01 16:17  麻辣咸鱼  阅读(3478)  评论(0编辑  收藏  举报