我有一个简单的程序如下:
#include <iostream>
using namespace std;
int main()
{
int N;
cout << "Enter N: " << endl;
cin >> N;
int acc = 0;
cin >> acc;
int min = acc;
int max = acc;
for (int i=1; i<N; i++) {
int current;
cin >> current;
acc += current;
if (current > max) {
max = current;
} else if (current < min) {
min = current;
}
}
cout << "Total: " + acc << endl;
cout << "Max: " + max << endl;
cout << "Min: " + min << endl;
return 0;
}
我的输出被截断如下
./stat
Enter N:
3
1
2
3
:
in:
我究竟做错了什么?