注册 登录
编程论坛 C++教室

输出以下图案

nardoloveme 发布于 2008-11-22 18:04, 2040 次点击
输出以下图案:
* * * * *
 * * * * *
  * * * * *
   * * * * *
大家有多少种方法请写出来,本人不是写不出来,只是想看看人家的程序或者学点巧妙的算法,谢谢了。
9 回复
#2
nardoloveme2008-11-22 18:07
* * * * * *
 * * * * * *
  * * * * * *
   * * * * * *
    * * * * * *
#3
nardoloveme2008-11-22 18:07
大概像个菱形
#4
newyj2008-11-22 19:39
c语言程序设计 上的一道题
无非 是用循环嵌套
lz 把代码贴 出来 看看呗
#5
江湖未冷2008-11-22 22:27
没太理解呀。。
怎么是大概像个菱形?大概的事情不好说吧
#6
scheelite2008-11-24 14:57
#include<stdio.h>
main()
{int i,j,k;
 for(i=0;i<5;i++)
 { if(i>1)
   for(j=0;j<i-1;j++)
     printf(" ");
   for(k=0;k<6;k++)
     printf("* "); printf("\n");
  }
 
}
#7
荒野的雄狮2008-11-24 20:46
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    for(int i=0;i<5;i++)
    {
            if(i!=1)
            {
                    for(int j=0;j<i;j++)
                            cout << " ";
            }
            for(int k=1;k<=6;k++)
                    cout << "* " ;
            cout << endl;
    }
    cout << endl;
    system("pause");
    return 0;
}
#8
yang_net2008-11-25 12:27
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    string chars;
    char c='*';
    cout<<"Please input the Rhombus' width:";
    int width,height;
    cin>>width;
    for(int i=1;i<=width;i++)
    {
        chars.append(&c,1);
    }
    cout<<"Please input the Rhombus' height:";
    cin>>height;
    for(int i=1;i<=height;i++)
    {
        cout<<chars<<endl;
        chars.insert(chars.begin(),' ');
    }
    return 0;
}
#9
sunkaidong2008-11-25 16:16
#include "stdio.h"
int main(void)
{
    for(int i=-1;i<4;i++)
    {  
        for(int j=0;j<5+i;j++)
             j<i?printf(" "):printf("*");
         printf("\n");
    }
    return 0;
}
#10
房屋的一角2008-11-25 18:04
回复 第1楼 nardoloveme 的帖子
#include <iostream>
#include<cstdlib>
using namespace std;
void main()
{
        int n=5;
    for(int i=0;i<5;i++) cout<<'*'<<' ';
    cout<<endl;
    for(int h=0;h<4;h++)
    {/* int n=5; */     //变量定义语句位置不同,输出结果也不同
        n--;
        for(int j=4;j>n;j--) cout<<' ';
        for(int i=1;i<=5;i++) cout<<'*'<<' ';
        cout<<endl;
    }
  
   
}
1