求100以内素数,要求调用自己写的函数
#include<iostream>
using namespace std;
int hanshu(int);
void main()
{
int x;
for(x=1;x<=100;x++)
{ hanshu(x);
if(hanshu(x)==1)
cout<<x<<" ";}
}
int hanshu(int x)
{int a,b=0;
for(a=1;a<=x;a++)
{if(x%a==0)
b+=a;
if(b==x+1)
return(1);
else
return(0);}
b=0;
}