c++编程!!! (图形的)

来源:百度知道 编辑:UC知道 时间:2024/05/21 09:39:06
*
***
*****
*******
*****
***
*
这样一个东西.
你们看看我编的,改错下..
最好不要改思路
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d,e;
for(a=1;a<=9;a++)
{
a=9;
for(b=1;b<=5;b++)
if(b%2!=0)
{
for(c=a;c>=1;c--)
cout<<" ";
for(c=1;c<=a;c++)
cout<<'*';
}
{
a=7;
if(a%2!=0)
for(d=1;c<=a;c++)
cout<<" ";
for(d=a;d>=a;c--)
cout<<'*';
}
}
system ("pause");
}
那个图形不对..
反正是一个菱形,由1,3,5,7,5,3,1个星号组成的

程序写的太混乱, 我给你个参考!

写程序, 首先要知道流程了怎么写的, 才能写好一个程序.
其次, 要把编程语言语言弄通了, 才有可能写出漂亮的程序.

#include "stdafx.h"
#include<iostream>
using namespace std;

int main()
{
int i,j;
int x=5; // 你可以在这里更改你想要的层数
for(i=1;i<=x*2;i+=2) // 上层金字塔
{
for(j=0;j<=x-i/2+1;j++) cout<<" ";
for(j=1;j<=i;j++) cout<<"*";
cout<<endl;
}
for(i=(x-1)*2;i>=1;i-=2) //// 下层金字塔
{
for(j=0;j<=x-i/2+2;j++) cout<<" ";
for(j=1;j<i;j++) cout<<"*";
cout<<endl;
}
system ("pause");
return 0;
}

#include<iostream>
using namespace std;

int main()
{
int i,j;
int x=5; // 你可以在这里更改你想要的层数
for(i=1;i<=x*2;i+=2) // 上层金字塔
{
for(j=0;j<=x-i/2+1;j++) cout<<" ";
for(j=1;j<=i;j++) cout<&l