按照现在的代码,哨兵被包括在平均值的计算中。关于如何在不包括哨兵的情况下打破循环的任何指示?
#include <iostream>
using namespace std;
int main ()
{
int fahr=0,cent=0,count=0,fav=0;
while (fahr!=-9999)
{
count ++;
cout<<"Input the fahrenheit temp to be converted to centigrade or enter -9999 "<<endl;
cin>>fahr;
cent=(float)(5./9.)*(fahr-32);
cout<<"The inputed fahr "<<fahr<<endl;
cout<<"The cent equivalent "<<cent<<endl;
}
fav=(float)(fav+fahr)/count;
cout<<"Average"<<fav<<endl;
return 0;
}