ACM Compilation Error
这是我变得程序,在VC里能运行。但是在OJ上却通不过。
大家帮我看下 哪错了
#include "stdafx.h"
#include"iostream"
using namespace std;
int main()
{
int N;
float x,y,z;
cin>>N;
int i;
for(i=0;i<N;i++)
{
cin>>x>>y;
z=(3.14*(x*x+y*y))/100;
cout<<"Property "<<i+1<<": This property will begin eroding in year "<< (int)(z+1)<<"."<<endl;
}
cout<<"END OF OUTPUT."<<endl;
return 0;
}
OJ地址:http://acm.nuc.edu.cn/OJ/problem.php?pid=1001
[解决办法]
是不是这个啊?
#include "stdafx.h"
不是那里都有的啊,MFC的玩意,全称 Standard Application Framework Extensions.
写成这样好点:
#include <iostream>using namespace std;int main(){ int N; float x,y,z; cin>>N; int i; for(i=0;i<N;i++) { cin>>x>>y; z = (float)(3.14*(x*x+y*y))/100; cout<<"Property "<<i+1<<": This property will begin eroding in year "<< (int)(z+1)<<"."<<endl; } cout<<"END OF OUTPUT."<<endl; return 0;}