此题如此之简单。。以至于= =。。无语。
hdu很轻松的就过了,但是bjfu上竟然怎么也过不了~~ 果然本校的oj还是有bug。。
#include <iostream>
using namespace std;
int main(){
int a,b;
while (cin>>hex>>a>>b){
cout<<a+b<<endl;
}
return 0;
}
复习一下进制的问题
hex %x 十六进制
oct %o 八进制
dec %d 十进制(默认)
#include <iostream>
using namespace std;
int main(){
int a,b;
cin>>hex>>a;
cin>>dec>>b;//一定要改回去,要不然默认还是输入十六进制
cout<<a<<endl;//同理
cout<<oct<<b<<endl;
return 0;
}
好吧,最终在bjfu上也过了。
是这样过的= =寒
#include <iostream>
using namespace std;
int main(){
__int64 a,b;//这里。。64位 寒。
while (cin>>hex>>a>>b){
cout<<dec<<a+b<<endl; //这个,鄙人认为改了输入流,没改输出流所以这个dec完全没必要。
}
return 0;
}
64位整型的定义方式有long long和__int64两种。
而输出到标准输出方式有printf(“%lld”,a),printf(“%I64d”,a),和cout << a三种方式。