正如标题所说,我不想使用系统(“暂停”),因为我不想开发一个坏习惯。 我不知道为什么它保持关闭,即使我有cin.get();即使我有cin.get();为什么我的应用程序关闭?
#include <iostream>
using namespace std;
float medel(int v[], int n)
{
float res = 0.0;
for (int i = 0; i < n; i++)
{
cin >> v[i];
res += ((double)v[i]/n);
}
return res;
}
int main() {
const int num = 10;
int n[num] = { 0 };
cout << "Welcome to the program. Enter 10 positive numbers: " << endl;;
cin.get();
cout << "The average of ten numbers entered is: " << medel(n, num) << endl;
cin.get();
return 0;
}
char x,while(x!='q'){cin.get();} –
你是如何学习C++的? 'cin.get();'不会读取10个数字,也不会将其读入任何东西。听起来你可以使用[良好的C++书](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) – NathanOliver