1樓:
供參考……
#include "stdafx.h"
#include "iomanip.h"
void d10to2_8_16(int i,char radix)void main(void)
編寫程式**:定義一個函式過程實現十進位制數轉換成二進位制數、八進位制數、十六進位制數的功能。 80
2樓:
#include "stdio.h"
#include "stdlib.h"
int main()
編寫一個function的過程,用於把一個十進位制的整數轉換成二進位制
3樓:匿名使用者
dim m as integer
private sub ***mand1_click()m = inputbox("請輸入一個數字")text1.text = fact(m)
end sub
public function fact(a as integer) as string
dim s as string, r as integerdo while a <> 0
r = a mod 2
a = a \ 2
s = str(r) & s
loop
fact = s
end function
4樓:銷聲匿跡
private function fact(a as integer)
dim s as string, r(100), i, j as integer
do until a = 0
i = i + 1
r(i) = a mod 2
a = a \ 2
loop
for j = i to 1 step 1s = s & r(i)
next j
fact=s
end function
5樓:橡皮樹的部落格
public function dec_to_bin(byval dec as long) as string
dec_to_bin = ""
do while dec > 0
dec_to_bin = dec mod 2 & dec_to_bin
dec = dec \ 2
loop
end function
vb編寫程式,利用sub過程實現將任意一個十進位制數n分別轉換成2進位制、8進位制和16進位制數。 要求
6樓:聽不清啊
private sub ***mand1_click()a = cint(text1.text)
s = ""
dec2n a, 2, s
print a; "=("; s; ")2"
dec2n a, 8, s
print a; "=("; s; ")8"
dec2n a, 16, s
print a; "=("; s; ")16"
end sub
sub dec2n(byval a, r, s)s = ""
while a > 0
x = a mod r
if x < 10 then s = x & s else s = chr(55 + x) & s
a = a \ r
wend
end sub
7樓:匿名使用者
這個大部分都做好了
你需要的話 可以幫你做
麻煩幫忙用vb做一個十進位制轉換為二進位制,八進位制,十六進位制的程式。**如下
8樓:網海1書生
private sub two_click() '二進位制dim b as long, s as stringb = val(text1.text)
do while b > 0
s = b mod 2 & s
b = b \ 2
loop
text2.text = s
end sub
private sub eight_click() '八進位制text3.text = oct(val(text1.text))end sub
private sub six_click() '十六進位制text4.text = hex(val(text1.text))end sub
9樓:匿名使用者
...........................可以幫你。
編寫vb程式 編寫sub過程 把任意一個十進位制數n分別轉換成二進位制八進位制十六進位制表示的數
10樓:匿名使用者
private function dectopoint(value as long, flag as long) as string
dim c as long
dim r as long
c = value if flag = 16 then
dectopoint = hex(c)
exit function
end if
dim s as string
dor = c mod flag
c = int(c / flag)
s = s & cstr(r)
loop until c < flag
s = s & cstr(c)
dectopoint = strreverse(s)
end functionprivate sub form_load()
dim value as long
value = 123
msgbox "value的二進位制
: " & dectopoint(value, 2)
msgbox "value的八進位制: " & dectopoint(value, 8)
msgbox "value的十六進位制: " & dectopoint(value, 16)
end sub
請編寫程式實現十進位制轉換為二進位制、八進位制、十六進位制。要求如下:
11樓:匿名使用者
這樣就將其轉化成10進位制了,你再將其轉化成二進位制就可以載得到八進位制和十六進位制了
12樓:楊武威
#include
void convert(unsigned int n, unsigned int r)
printf("\n");
break;
case 8:
printf("%o\n",n);
break;
case 16:
printf("%x\n",n);
break;
default:
printf("error input r!\n");}}int main()
編寫vb程式 編寫sub過程 把任意一個十進位制數n分別轉換成二進位制八進位制十六進位制表示的數
13樓:匿名使用者
設計介面
:**:
private sub ***mand1_click()
dim integerpart as long, decimalpart as double
dim carry(), charactercode(15) as string
carry = array(2, 8, 16)
integerpart = int(val(text1.text))
decimalpart = val(text1.text) - int(val(text1.text))
for i = lbound(charactercode) to ubound(charactercode)
select case i
case 0 to 9
charactercode(i) = chr(48 + i)
case else
charactercode(i) = chr(55 + i)
end select
next i
for i = lbound(carry) to ubound(carry)
label2(i) = transformation(carry(i), charactercode, integerpart, decimalpart)
next i
end sub
private function transformation(byval carrysystem as integer, byref charactercode() as string, byval integerpart as long, byval decimalpart as double) as string
dim r as integer, strintegerpart as string, q as integer, strdecimalpart as string
dor = integerpart mod carrysystem
integerpart = integerpart \ carrysystem
strintegerpart = charactercode(r) + strintegerpart
loop until integerpart = 0
doq = int(decimalpart * carrysystem)
decimalpart = decimalpart * carrysystem - q
strdecimalpart = strdecimalpart + charactercode(q)
loop until decimalpart = 0
transformation = strintegerpart + "." + strdecimalpart
end function
執行介面:
用vb程式設計:將二進位制轉化為十進位制。
14樓:匿名使用者
private sub form_load()msgbox bin_to_dec("11")end sub
public function bin_to_dec(byval bin as string) as long
dim i as long
for i = 1 to len(bin)bin_to_dec = bin_to_dec * 2 + val(mid(bin, i, 1))
next i
end function
15樓:匿名使用者
編寫程式,使用函式過程的方式求和數s
int sum int n int bosum int n 呵呵,自己推下公式吧 s 1 1 2 1 2 3 1 2 3 n n n 1 2 n 1 12 n n 1 4 n n 1 n 2 6 public function ssum byval n as int32 as int32 retur...
vb60要求編寫function過程在文字框中輸入
寫了一段,窗 bai體上放du一個text,一個按鈕zhi,如下 daofunction sushu a as integer as integer for i 2 to a 1 step 1if a mod i 0 then msgbox a 不為素數 vbinformation vbokonly...
編寫function的過程用於把十進位制的整數
dim m as integer private sub mand1 click m inputbox 請輸入一個數字 text1.text fact m end sub public function fact a as integer as string dim s as string,r as...