hex表示十六进制,oct表示八进制,dec表示十进制,默认是十进制
十六进制输入:
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>hex>>a>>hex>>b)
cout<<a+b<<endl;
return 0;
}
八进制输入:
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>oct>>a>>oct>>b)
cout<<a+b<<endl;
return 0;
}
十进制输入:
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>dec>>a>>dec>>b)
cout<<a+b<<endl;
return 0;
}
//默认十进制
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
cout<<a+b<<endl;
return 0;
}
C++中输入不同的进制数字挺方便的,哈哈!