c++ - c ++中文件输入输出中的long long v / s int
问题描述
我尝试了许多不同的不成功方法,我将在下面描述最后一种方法-
#include<iostream>
#include<fstream>
//functions here
using namespace std;
int main(){
int n;
long long A[300001];
ifstream myfile("sort.in");
myfile>>n;
for(int i=0;i<n;++i){
myfile>>A[i];
}
cout<<A[0];
myfile.close();
return 0;
}
这行不通。
而下面的一个有效 -
#include<iostream>
#include<fstream>
//functions here
using namespace std;
int main(){
int n;
int A[300001];
ifstream myfile("sort.in");
myfile>>n;
for(int i=0;i<n;++i){
myfile>>A[i];
}
cout<<A[0];
myfile.close();
return 0;
}
问题是什么?
唯一的区别是使用 int 而不是 long long。怎么会有这么大的不同?顺便说一句,不工作是指它没有在屏幕上产生任何输出。解决方案
推荐阅读
- javascript - 如何访问对应的 Vue-component rsp。ThreeJs Raycaster 的用户数据?
- google-bigquery - 在 Dataproc 中为 BQ 数据初始化 sql 查询时出现错误
- android-studio - 使用当前代码向 Kotlin okHttp retrofit2 中的每个请求添加自定义标头
- google-apps-script - App Scripts 用相同级别的新列表项替换 Google Doc 中的字符串,而不更改列表样式
- vba - Wscript.Shell Exec 中的“编码”一词确实会阻止 powershell 脚本运行。我能做些什么?
- python - 调用 export_png 时未反映散景图的更改(例如缩放)
- docker - 在无根 docker 中运行图像,图像未显示
- c++ - 文件创建失败,因为我无法添加名称
- vba - Excel 宏需要多次执行才能正常运行
- flutter - 颤振网;Riverpod Firebase 身份验证;热重启/重新加载 - 用户会话丢失?