Προς το περιεχόμενο

help se c++


alterego

Προτεινόμενες αναρτήσεις

paidia mporeite na boithisete sto parakato?an doulepsei pername ergasthrio pliroforikis sto opoion exoume mayra mesanyxta.to thema einai:na kataskeyastei antikeimeno to opoio prosomoionei ti leitourgia enos athroisti enos bit.na kataskeyastei programma to opoio athroizei kai afairei akeraious arithmous 32 bit. An mporei kapoios... frown.gif" border="0

Συνδέστε για να σχολιάσετε
Κοινοποίηση σε άλλες σελίδες

class bit {<P>unsigned int value;<BR>unsigned int borrow;<BR>unsigned int carry;<P>public:<BR>//constructor<BR>bit() <BR>{<BR> value=0;<BR> borrow=0;<BR> carry=0;<BR>}<P>//destroy<BR>~bit()<BR>void setValue(unsigned int pvalue)<BR>{<BR>value=pvalue;<BR>}<P>unsigned int getValue()<BR>{<BR>return value;<BR>}<P>unsigned int getCarry()<BR>{<BR>return carry;<BR>}<P>void add(unsigned int bit1, unsigned int pcarry)<BR>{<BR> value+=(bit1+pcarry);<BR> carry=(value>1)?1:0;<BR> value&=0x0001;<BR>return carry;<BR>}<BR>}<P>void main()<BR>{<BR>bit int1[32], int2[32], sum[32];<BR>unsigned int num1,num2;<BR>num1=0x0fe00;<BR>num2=0x034d3;<P>for (int n=0; n<32; n++)<BR> {<BR> int1[n].setValue(num1 & (1<<n));<BR> int2[n].setValue(num2 & (1<<n));<BR> sum[n].setValue(int1[n].getValue())<BR> if (n==0) sum[n].add(int2[n].getValue(),0) else sum[n].add(int2[n].getValue, sum[n-1].getCarry())<BR>}<P>}<P>Kati paromoio kaneis kai gia tin afairesi. An den ta katafereis kai exw xrono tha to kanw kai auto.

Συνδέστε για να σχολιάσετε
Κοινοποίηση σε άλλες σελίδες

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...