2个回答
展开全部
Dim arrYangHui%(10, 10)
Dim i, j%
For i = 1 To 10
arrYangHui(i, 1) = 1
arrYangHui(i, i) = 1
Next
For i = 2 To 10
For j = 2 To i - 1
arrYangHui(i, j) = arrYangHui(i - 1, j - 1) + arrYangHui(i - 1, j)
Next
Next
Dim MyGraphics As Graphics
' 声明图形变量
MyGraphics = Me.CreateGraphics()
' 将当前窗体设置为图形对象
Dim MyFont As New Font("隶书", 14, FontStyle.Regular, GraphicsUnit.Point)
' 声明字体对象
Dim MyBrush As New SolidBrush(Color.Black)
' 声明黑色的刷子对象
Dim MyPos As New PointF(0, 0)
' 声明一个点对象
Dim strChars$, intLen%
For i = 1 To arrYangHui.GetUpperBound(0)
MyPos.X = 0
For j = 1 To i
strChars = Trim(Str(arrYangHui(i, j)))
intLen = Len(strChars)
strChars = Space(8 - intLen) & strChars
MyGraphics.DrawString(strChars, MyFont, MyBrush, MyPos)
MyPos.X += 8 * MyFont.Size * 2 / 3
' 字体的全身大小的2/3
Next
MyPos.Y += MyFont.GetHeight()
' 字体的行距
Next
Dim i, j%
For i = 1 To 10
arrYangHui(i, 1) = 1
arrYangHui(i, i) = 1
Next
For i = 2 To 10
For j = 2 To i - 1
arrYangHui(i, j) = arrYangHui(i - 1, j - 1) + arrYangHui(i - 1, j)
Next
Next
Dim MyGraphics As Graphics
' 声明图形变量
MyGraphics = Me.CreateGraphics()
' 将当前窗体设置为图形对象
Dim MyFont As New Font("隶书", 14, FontStyle.Regular, GraphicsUnit.Point)
' 声明字体对象
Dim MyBrush As New SolidBrush(Color.Black)
' 声明黑色的刷子对象
Dim MyPos As New PointF(0, 0)
' 声明一个点对象
Dim strChars$, intLen%
For i = 1 To arrYangHui.GetUpperBound(0)
MyPos.X = 0
For j = 1 To i
strChars = Trim(Str(arrYangHui(i, j)))
intLen = Len(strChars)
strChars = Space(8 - intLen) & strChars
MyGraphics.DrawString(strChars, MyFont, MyBrush, MyPos)
MyPos.X += 8 * MyFont.Size * 2 / 3
' 字体的全身大小的2/3
Next
MyPos.Y += MyFont.GetHeight()
' 字体的行距
Next
追问
这是什么语言?不是vb吧?
展开全部
//yanghui.c
#include<stdio.h>
//Yang
int yang(int x, int y)
{
if(y == 1 || x == y){
return 1;
}
return yang(x - 1, y - 1) + yang(x - 1, y);
}
//Print space
void printspace(int n)
{
int i;
for(i = 0; i < n ; i++){
printf(" ");
}
}
//The main function
int main()
{
int i, j, line;
printf("Please input a number:\n");
scanf("%d", &line);
for(i = 1; i <= line; i++){
printspace((line - i) * 5);
for(j = 1; j <= i; j++){
printf("%10d", yang(i, j));
}
printf("\n");
}
return 0;
}
更多追问追答
追问
vb程序?
追答
c
vb可以改
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询