读书人

ACM Compilation Error,该如何解决

发布时间: 2012-11-05 09:35:12 作者: rapoo

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.

写成这样好点:

C/C++ code
#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;} 

读书人网 >C++

热点推荐