1樓:總有點數學小感悟
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
2樓:匿名使用者
//yanghui.c
#include
//yang
int yang(int x, int y)return yang(x - 1, y - 1) + yang(x - 1, y);
}//print space
void printspace(int n)}//the main function
int main()
printf("\n");
}return 0;}
vb.net的問題,輸入整數n,顯示具有n行的楊輝三角形。 20
3樓:
參考:以下為十行的楊輝三角輸出,根據這個自己做相應修改,都做好了,那你就是伸手黨了。
public class form1
private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.
click
dim i, j as integer
dim n as integer
n = 10
dim dete(n, n) as integerdim sum as integer
for i = 0 to n
for j = 0 to i
if i = 0 then
dete(i, j) = 1
elseif j = 0 then
dete(i, j) = 1
elseif i = j then
dete(i, j) = 1
else
dete(i, j) = dete(i - 1, j - 1) + dete(i - 1, j)
end if
next
next
for i = 0 to n
for j = 0 to i
debug.write(dete(i, j) & " ")sum += dete(i, j)
next
debug.writeline(" ")
next
end sub
end class
輸入整數n,顯示出具有n行的楊輝三角形。vb程式設計,跪求。
4樓:oooo泡
源**如下:
private sub form_click() n = inputbox("", "", 5) redim a(n + 1, n + 1), b(n + 1, n + 1) cls k = 8 for i = 1 to n print string((n - i) * k / 2 + 1, " "); for j = 1 to i a(i, 1) = 1 a(i, i) = 1 a(i + 1, j + 1) = a(i, j) + a(i, j + 1) b(i, j) = trim(str(a(i, j))) print b(i, j); string(k - len(b(i, j)), " "); next j print next iend sub執行程式,在文字框輸入8,再點窗體,效果圖如下:
5樓:遠風的夢想家
private sub form_click()dim a() as long, n as integer, i as integer, j as integer
n = val(inputbox("請輸入"))redim a(n, n)
me.cls
for i = 1 to n
for j = 1 to i
if j = 1 or i = j thena(i, j) = 1
else
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
end if
next j
next i
for i = 1 to n
for j = 1 to i
print a(i, j);
next j
next i
end sub
6樓:匿名使用者
這些都是我做過的考試要求,- - 不過忘記了
7樓:匿名使用者
''輸出楊輝三角形
private sub command1_click()dim x as string, i as integer, j as integer, n as integer
dim a() as integer
n = val(inputbox("請輸入行數:"))redim a(1 to n, 1 to n)for i = 1 to n
for j = 1 to i
if j = 1 or i = j thena(i, j) = 1
else
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
end if
next j
next i
for i = 1 to n
x = ""
for j = 1 to i
x = x & a(i, j) & space(1)next j
print space(n - i + 5) & x & chr(13)
next i
end sub
'除錯成功
8樓:匿名使用者
private sub yh(byval n as integer)dim a(n, n) as integerfor i as integer = 0 to na(i, 0) = 1
next
for i = 0 to n - 1
for j as integer = 1 to ia(i, j) = a(i - 1, j - 1) + a(i - 1, j)
next
next
label1.text = ""
for i = 0 to n - 1
for j = 0 to i
label1.text += a(i, j).tostring() + " "
next
label1.text += vbcrlfnext
end sub
輸入一個小於10的正整數n,顯示具有n行的楊輝三角。。求程式設計!!
9樓:匿名使用者
#include
using namespace std;
//pl是用來求排列數的 jc是用來求階乘的long pl(int,int);
long jc(int);
int main()
return 0;
}//求排列數
long pl(int m,int n)
//求階乘
long jc(int p)
//經測試,輸入的n<=13時都沒有問題
//如果再大一點,就要把程式裡面部分long替換成float或者double
10樓:匿名使用者
#include
#define n 3
int main()
printf("%d\n",sum);
return 0;}
11樓:匿名使用者
#include
int main()
}void int c(int x,int y) /*求楊輝三角形中第x行第y列的值*/
這個改改就行了
c++輸入一個小於10的正整數n,顯示具有n行的楊輝三角形。下面是我編的程式,**有問題
輸入整數n,顯示出具有n行的楊輝三角形。vb程式設計,跪求
oooo泡 源 如下 private sub form click n inputbox 5 redim a n 1,n 1 b n 1,n 1 cls k 8 for i 1 to n print string n i k 2 1,for j 1 to i a i,1 1 a i,i 1 a i ...
輸入正整數n計算11315的前n項
include int main for i 1 i n i printf sum 3f n sum return 0 示例執行結果 20sum 2.480 include int main void for int i 0 iprintf 數列前 d 項之和為 g n n,s return 0 v...
這個題怎麼做呀 輸入整數n,列印n行的楊輝三角 n為輸
include stdio.h define size 16 void main linshi size printf 請輸入楊輝三角的行數n 16 n scanf d n for i 0 ii sanjiao j 1 else sanjiao j linshi j 1 linshi j print...