驾校招生宣传词:求,用C语言编写一个程序

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/24 01:40:22
用二维数组输出一个图形
第一行一个*
第二行二个**
第三行三个***
第四行二个**
第五行一个*
要求成为菱形!

#include <stdio.h>
int main(char* a,char** b)
{
printf(" *\n **\n ***\n **\n *\n");
return 0;
}

hehe ,have a joke~

follow is entire segment:

#include <stdio.h>
int main(char* a,char** b)
{
char c[5][3];int a,b;
c[0][0]='*';
c[1][0]=c[1][1]='*';
c[2][0]=c[2][1]=c[2][2]='*';
c[3][0]=c[3][1]='*';
c[4][0]='*';
for(a=0;a<6;a++)
for(b=0;b<3;b++)
if(c[a][b]=='*')
print("%c",c[a][b]);
print("\n");
return 0;
}

by the way:why use the 2D array?

main()
{char dia[ ][5]={{'','','*'}
,{'','*','','*'},
{'*','','*','','*'},
{'','*','','*'}
{'','','*'}};
int i,j;
for(i=0;i<5;i++)
{for(j=0;j<5;j++)
print("%c",dia[i][j]);
print(""\n);
}}

int arr[5][3] = {{0,0,1,0,0},{0,1,0,1,0},{1,0,1,0,1},{0,1,0,1,0},{0,0,1,0,0}};
int i, j;

for(i = 0; i < 5; i++)
{
for(j = 0; j < 3; j++)
{
printf((arr[i][j] == 1 ? '*' : '_')); // _ 为空格
}
printf("\n");
}

*
* *
* * *
* *
*

一定要用二维数组么?

#include <iostream.h>
#include <iomanip.h>
void main()
{
cout<<"**********************************************"<<endl;
cout<<" ****大学软件工作室**** "<<endl;
cout<<"**********************************************"<<endl;
char a[5][3]={'*'};
cout<<setw(21)<<a[0][0]<<endl;
cout<<setw(20)<<a[0][0]<<setw(2)<<a[0][0]<<endl;
cout<<setw(19)<<a[0][0]<<setw(2)<<a[0][0]<<setw(2)<<a[0][0]<<endl;
cout<<setw(20)<<a[0][0]<<setw(2)<<a[0][0]<<endl;
cout<<setw(21)<<a[0][0]<<endl;
}
如果你傻的可爱,你可以试试哦~~~~~嘻嘻

我觉得应该到专门的c论坛去讨论类似的问题。
祝你早日成才!

For i= 1 to 2
Print TABA (9-i);
For x= 1 to 2 * i - 1
Print "*",
Next x
Print
Next i
For i=3 to 1 step -1
Print TAB (9-i);
For x= 1 to 2 * i -1
Print "*";
Next x
Print
Next i
End