我的老师通常从一个开始索引数组.所以,基本上,当我们需要他使用的100个元素的数组时
int a[101]
Run Code Online (Sandbox Code Playgroud)
代替
int a[100]
Run Code Online (Sandbox Code Playgroud)
例如,他像这样填写:
for (int i = 1; i <= 100; i++)
cin >> a[i];
Run Code Online (Sandbox Code Playgroud)
使用这种方法有什么问题,还是应该避免使用?(从0开始处理索引时没有任何问题)
我一直试图建立一个小型库来处理大整数,就像练习一样,但我没有明显的理由得到这个错误:
使用重载运算符'+'是不明确的(操作数类型'BigNum :: BigInt'和'int')
这是类定义:
namespace BigNum {
class BigInt {
public:
BigInt();
BigInt(int64_t n);
BigInt(std::string s);
friend std::istream& operator>> (std::istream& in, BigInt& n);
friend std::ostream& operator<< (std::ostream& out, BigInt n);
friend bool operator< (const BigInt& a, const BigInt& b);
friend bool operator> (const BigInt& a, const BigInt& b);
friend bool operator== (const BigInt& a, const BigInt& b);
friend bool operator!= (const BigInt& a, const BigInt& b);
friend bool operator<= (const BigInt& a, const BigInt& b);
friend bool operator>= (const …Run Code Online (Sandbox Code Playgroud)