c语言中用while(scanf(。。。)!=EOF)来实现一次运行的多次输入。 c++为什么不能用while(cin>>(。。。)!=EOF)来实现? 改怎么改? 如下程序为什么不行?
#include
using namespace std;
#define pi 3.1415926
const double PI=3.14;
int main()
{ system("color 4A");
double s1,s2,r;
while((cin>>r)!=EOF)
{
s1=PI*r*r;
s2=pi*r*r;
cout<<"s1="<<s1<<endl;
cout<<"s2="<<s2<<endl;
}
system("pause");
}