我有一個簡單的程序如下:爲什麼我的字符串在C++中打印不正確?
#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:
我在做什麼錯?