编程输出以下图形 * *** ***** ***
编程输出以下图形*************要求使用双循环,外层循环控制行数,内层循环分别控制空格和星号“*”输出)...
编程输出以下图形
*
***
*****
***
*
要求使用双循环,外层循环控制行数,内层循环分别控制空格和星号“*”输出) 展开
*
***
*****
***
*
要求使用双循环,外层循环控制行数,内层循环分别控制空格和星号“*”输出) 展开
3个回答
展开全部
#include<stdio.h>
int main()
{int i,j,n;
n=3;
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
printf(" ");
for(j=0;j<2*i+1;j++)
printf("*");
printf("\n");
}
for(i=n-2;i>=0;i--)
{
for(j=0;j<n-i-1;j++)
printf(" ");
for(j=0;j<2*i+1;j++)
printf("*");
printf("\n");
}
return 0;
}
展开全部
Public Function Diamond(ByVal num As Integer) As String
Dim i, j As Integer, st As String = ""
If (num Mod 2 = 0) Then
Return ""
End If
'输出上三角形
For i = 1 To (num + 1) \ 2
For j = 1 To (num + 1) / 2 - i
st = st & " "
Next
For j = 1 To 2 * i - 1
st = st & "*"
Next
st = st & vbCrLf
Next
'输出下三角形
For i = 1 To (num - 1) \ 2
For j = 1 To i
st = st & " "
Next
For j = 1 To num - 2 * i
st = st & "*"
Next
st = st & vbCrLf
Next
Return st
End Function
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim str As String = ""
str = Diamond(7)
TextBox6.Text = str
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#define LINE 10 /*控制显示的行*/
#define ROW 20 /*控制显示的列*/
void paintStar(int y, int x, int num)
{
int i;
char far* p = (char far*)(0xb8000000 + 160 * y + 2 * x);
for(i=0; i<num; i++, p+=2) *p = '*';
}
main()
{
int line, row;
int arr[] = {1,3,5,7,5,3,1};
row = ROW;
for(line=0; line<7; line++)
{
paintStar(line+LINE, row, arr[line]);
row = (row - 2) < (ROW-6) ? (ROW-6) : (row - 2);
}
}
#define ROW 20 /*控制显示的列*/
void paintStar(int y, int x, int num)
{
int i;
char far* p = (char far*)(0xb8000000 + 160 * y + 2 * x);
for(i=0; i<num; i++, p+=2) *p = '*';
}
main()
{
int line, row;
int arr[] = {1,3,5,7,5,3,1};
row = ROW;
for(line=0; line<7; line++)
{
paintStar(line+LINE, row, arr[line]);
row = (row - 2) < (ROW-6) ? (ROW-6) : (row - 2);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询