26 lines
412 B
C++
26 lines
412 B
C++
|
|
#include<bits/stdc++.h>
|
|||
|
|
using namespace std;
|
|||
|
|
|
|||
|
|
int quick(int a,int b)
|
|||
|
|
{
|
|||
|
|
int s = 1;
|
|||
|
|
while (b > 0) {
|
|||
|
|
if (b & 1) {//b=b>>1<><31>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>϶<EFBFBD><CFB6><EFBFBD>ִ<EFBFBD>и<EFBFBD>if<69>ж<EFBFBD>
|
|||
|
|
s = s * a;
|
|||
|
|
}
|
|||
|
|
a = a * a;
|
|||
|
|
cout<<"b="<<b<<endl;
|
|||
|
|
cout<<"s="<<s<<endl;
|
|||
|
|
cout<<endl;
|
|||
|
|
b = b >> 1;
|
|||
|
|
}
|
|||
|
|
return s;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int main() {
|
|||
|
|
printf("%d",quick(2,10));
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|