#include<iostream>#include<math.h>usingnamespacestd;
int main()
{
int t,i,j;
for(i=2;i<=100;i++)
{
t=sqrt(i);
for(j=2;j<=t;++j)
{
if(i%j==0)
break;
}
if(j>t)
cout<<i<<endl;
}
return0;
}
2_32源码:
#include<iostream>#include<cstdlib>usingnamespacestd;
int random()
{
int num;
return (num = 1 + rand() % 100);
}
int main()
{
int a,num;
unsigned seed;
cout << "please enter an unsigned integer:" << endl;
cin >> seed;
srand(seed);
num = random();
cin >> a;
while (a !=num)
{
if (a > num)
{
cout << "The guess is bigger"<<endl<<"Please try again"<<endl;
}
elseif (a < num)
{
cout << "The guess is smaller"<<endl<<"Please try again"<<endl;
}
cin>> a;
}
cout<<"Congratulation!";
return0;
}
2_34源码:
#include<iostream>usingnamespacestd;
int main()
{
int i,j,k,n=0;
for (i=0;i<5;i++)
for (j=i+1;j<5;j++)
for (k=j+1;k<5;k++)
{
if (i != j && j !=k && k!=i)
n++;
}
cout<<n;
return0;
}