基本没啥问题,只是楼主对C++一些语法还不是很熟练。楼主的方程中 a>100 && a<200 这一句,C++是完全无法识别的。估计楼主是想给a定一个范围吧,但是C++里面不是这么定义的,这种时候应该建立循环,从100开始,循环到200,逐个判断。循环可以使用for循环和while循环,我两种都写一下吧。
下面给出我修改后的答案。
#include "stdafx.h"
#include <iostream>
#include "math.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
for(int a=100;a<=200;a++){
if (a%2==0 || a%3==0 || a%5==0 || a%7==0 || a%11==0 || a%13==0 || a%17==0)
cout<<' '<<endl;
else
cout<<a<<endl;
}
return 0;
}
#include "stdafx.h"
#include <iostream>
#include "math.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a=100;
while(a!=200){
if (a%2==0 || a%3==0 || a%5==0 || a%7==0 || a%11==0 || a%13==0 || a%17==0)
cout<<' '<<endl;
else
cout<<a<<endl;
a++;
}
return 0;
}
温馨提示:内容为网友见解,仅供参考