
杭电ACM测试系统是不是有问题,在我的机子上编译没有问题,为什么一提交就编译错误
别的一切错误我都可以接受。但是是编译错误啊!!CompilationError根本还没有到执行的阶段.我使用的是企业版的VC6,应该没有问题。还是谢谢大家的回复了。以下是...
别的一切错误我都可以接受。但是是编译错误啊!!Compilation Error根本还没有到执行的阶段.我使用的是企业版的VC6,应该没有问题。
还是谢谢大家的回复了。以下是代码:
#include<iostream>
using namespace std;
bool function(int te)
{
if(te<2)
return false;
else if(te==2)
return true;
else
{
for(int i=2;i<te;++i)
if(te%i==0)
break;
if(i==te)
return true;
else
return false;
}
return true;
}
int main()
{
int x,y;
while(cin>>x>>y && (x!=0 || y!=0))
{
for(int j=x;j<=y;++j)
if(!function(j*j+j+41))
break;
if(j==y+1)
cout<<"OK"<<endl;
else
cout<<"Sorry"<<endl;
}
return 0;
}
杭电2012题: 展开
还是谢谢大家的回复了。以下是代码:
#include<iostream>
using namespace std;
bool function(int te)
{
if(te<2)
return false;
else if(te==2)
return true;
else
{
for(int i=2;i<te;++i)
if(te%i==0)
break;
if(i==te)
return true;
else
return false;
}
return true;
}
int main()
{
int x,y;
while(cin>>x>>y && (x!=0 || y!=0))
{
for(int j=x;j<=y;++j)
if(!function(j*j+j+41))
break;
if(j==y+1)
cout<<"OK"<<endl;
else
cout<<"Sorry"<<endl;
}
return 0;
}
杭电2012题: 展开
2个回答
展开全部
那就是你的写法还不够标准吧。你用的编译环境是什么。
如果你的编译器有些地方不是标准的,那就有可能会这样了,如vc6
如果你的编译器有些地方不是标准的,那就有可能会这样了,如vc6

2025-03-07 广告
力控组态软件与S7-1500 PLC通讯故障时,首先检查硬件连接,确保线缆无损、接口紧固。接着,验证配置设置,包括波特率、数据位、停止位等是否一致。同时,检查防火墙或安全设置,确保通讯端口未被阻塞。若问题依旧,尝试更新或重装驱动程序和通讯软...
点击进入详情页
本回答由力控科技提供
展开全部
// 代码已AC
#include<iostream>
using namespace std;
bool function(int te)
{
if(te < 2)
return false;
else if(te == 2)
return true;
else
{
for(int i = 2; i < te; ++i)
if(te % i == 0) //非素数,直接返回 false
// break;
// if(i == te)
// return true;
// else
return false;
}
return true;
}
int main()
{
int j,x, y; //变量j放在前面定义,因为后面还有用到
while(cin >> x >> y && (x != 0 || y != 0))
{
for(j = x; j <= y; ++j)
if(!function(j * j + j + 41))
break;
if(j == y + 1)
cout << "OK" << endl;
else
cout << "Sorry" << endl;
}
return 0;
}
//祝你学习进步,更上一层楼!(*^__^*)
#include<iostream>
using namespace std;
bool function(int te)
{
if(te < 2)
return false;
else if(te == 2)
return true;
else
{
for(int i = 2; i < te; ++i)
if(te % i == 0) //非素数,直接返回 false
// break;
// if(i == te)
// return true;
// else
return false;
}
return true;
}
int main()
{
int j,x, y; //变量j放在前面定义,因为后面还有用到
while(cin >> x >> y && (x != 0 || y != 0))
{
for(j = x; j <= y; ++j)
if(!function(j * j + j + 41))
break;
if(j == y + 1)
cout << "OK" << endl;
else
cout << "Sorry" << endl;
}
return 0;
}
//祝你学习进步,更上一层楼!(*^__^*)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询