输入:7182933164 输出:2147483647 (这不是我知道缺少的所有代码})
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string line;
ifstream file("Numbers.txt");
int num;
cout << "Enter credit card number : " << endl;
cin >> num;
cout << "enterned : " << num << endl;
答案 0 :(得分:2)
值7182933164
如此之大,以至于它可以容纳的整数(即-2147483648 to 2147483647
)的值越过。使用long
类型修饰符接受此类值。并且,如果只需要正整数,请在unsigned
之前添加long
。
执行以下操作:
...
long num; // dependent upon the computer architecture
...
如果这不起作用,请尝试long long
。尽管在OnlineGDB (example)中可以正常工作。
答案 1 :(得分:2)
使用std:: string
代表代码编号。