C????????λ?????
?????hack_ctf ???????[ 2017/3/2 11:01:31 ] ????????.NET C????
???????????????????μ???????????????????????????????????ü??????????????.
??????c???????.??????????????????????????ü??ζ??д??.
????????????????????????????Щ?????????????????????????????.???????????.?????????д??
?????????θ????е??????????.
??????????ü????????????????д??????????????????????????.
?????????д????????????????3λ?????????4λ?????.
?????????????????????????????????д??λ???????????????????????д???λ?????????.
?????? S(i)????iλ????????C(i)???iλ???λ??A(i)??B(i)??????????????
???????????????????:
????S(i) = A(i)^B(i)^C(i-1)
????C(i) = (A(i)&B(i))|((A(i)^B(i))&C(i-1))
??????????????????????????????:
#include <iostream>
#include <math.h>
using namespace std;
int add(int a??int b){
bool a_array[32]; //?洢a???????λ
bool b_array[32]; //?洢b???????λ
bool result[32]; //??????
bool c=0; //?????????λ
int res=0;
int i;
for(i=0;i<32;i++){
a_array[i] = a & (1<<i);
b_array[i] = b & (1<<i);
result[i] = a_array[i]^b_array[i]^c;
c = (a_array[i]&b_array[i])|((a_array[i]^b_array[i])&c);
res = res + (unsigned int)(result[i])*pow(2??i);
}
return res;
}
int main(int argc ??char** argv){
int a;
int b;
cin>>a;
cin>>b;
cout<<add(a??b)<<endl;
return 0;
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11