求大神用vb程式編寫給定整數N,求該整數的原碼,反碼,補碼的程式

2021-04-18 22:26:29 字數 2818 閱讀 3005

1樓:聽不清啊

private sub command1_click()dim a(16) as integer, x as integerx = cint(text1.text)

if x >= 0 then a(16) = 0 else a(16) = 1

x = abs(x)

for i = 1 to 15

a(i) = x mod 2

x = x \ 2

next i

text2.text = ""

for i = 16 to 1 step -1text2.text = text2.text & a(i)next i

if a(16) = 0 then

text3.text = text2.texttext4.text = text2.textexit sub

end if

for i = 1 to 15

a(i) = 1 - a(i)

next i

text3.text = a(16)

for i = 15 to 1 step -1text3.text = text3.text & a(i)next i

text4.text = a(16)

a(1) = a(1) + 1

i = 1

while a(i) = 2 and i < 15a(i) = 0

a(i + 1) = a(i + 1) + 1i = i + 1

wend

for i = 15 to 1 step -1text4.text = text4.text & a(i)next i

end sub

一個整數n,用vb程式設計求它的原碼,補碼和反碼。

2樓:聽不清啊

private sub command1_click()dim a(16) as integer, x as integerx = cint(text1.text)

if x >= 0 then a(16) = 0 else a(16) = 1

x = abs(x)

for i = 1 to 15

a(i) = x mod 2

x = x \ 2

next i

text2.text = ""

for i = 16 to 1 step -1text2.text = text2.text & a(i)next i

if a(16) = 0 then

text3.text = text2.texttext4.text = text2.textexit sub

end if

for i = 1 to 15

a(i) = 1 - a(i)

next i

text3.text = a(16)

for i = 15 to 1 step -1text3.text = text3.text & a(i)next i

text4.text = a(16)

a(1) = a(1) + 1

i = 1

while a(i) = 2 and i < 15a(i) = 0

a(i + 1) = a(i + 1) + 1i = i + 1

wend

for i = 15 to 1 step -1text4.text = text4.text & a(i)next i

end sub

c語言程式題,任意輸入一個整數,編一個程式,使其輸出輸出相應的原碼、反碼及補碼。

3樓:great啦啦啦

程式如下:

#include

void main()}

4樓:

||**資料:

#include "stdio.h"

#include "limits.h"

void myout(unsigned n)int main(int argc,char *argv)printf("%d:\n",n);

printf("原碼專: ");

myout(n>=0 ? n : (~n+1)|~int_max);

printf("\n反碼: ");

myout(n>=0 ? n : ~(-n));

printf("\n補碼屬: ");

myout(n);

putchar('\n');

return 0;}

用c語言編一個程式,使給出一個數的原碼,求得反碼,補碼。

5樓:匿名使用者

#include

int main()

j = i-1;

ab[0] = af[0] = a[0];//符號位始終不變if(a[0] == 1)

}k = i;

for(; i > 0; i--)

af[i] = 1 - a[i];

for(i = k; i > 0; i--)//補碼從末位數起第一個不為0,以後均取反

ab[i] = 1 - a[i];

}else

}printf("對應的反碼是:\n");

for(i = 0; i <= j; i++)printf("%d", af[i]);

printf("\n");

printf("對應的補碼是:\n");

for(i = 0; i <= j; i++)printf("%d", ab[i]);

}在vc下編譯測試通過。另,本**未考慮輸入非法問題,所輸入的數字智慧由1和0組成

vb編寫用於求隨機數的程式,vb編寫一個用於求隨機數的程式

private sub form mousedown button as integer,shift as integer,x as single,y as single dim i as integer,f as doublerandomize if button vbkeylbutton the...

用C語言編寫程式 輸入實數x和正整數n,計算x的n次方,不許

include main bai int digitmf int x,int n return y include int main void return 0 include int main printf 3lf n sum 輸出sum return 0 include main 你試試看可da...

求大神用c語言編寫這道程式,求大神用c語言編寫這道程式

請家現再幫我解決補充問題 間 20137月514 44 25 目 想用if功能實現輸入字元y則顯示123否則顯示321 include char main void 何輸入char或者int結都確 vc6.0執行結 請輸入 y n y 12 ress any key to continue請輸入 y...