c++ so nguyen to (q)
//............................
//Ho ten: Pham Cong Quang.
//class: K53CA_N2
//project:
//purpose:
//............................
#include <iostream>
using namespace std;
main()
{
int n,a,b,c;
cout << "n= ";
cin >> n;
cout << "cac so nguyen to nho hon hoac bang " << n << ": " <<endl;
for (a=2;a<=n;a++){
c=1;
for (b=2;b<=a/2;b++)
if (a%b==0)
c=0;
if (c==1)
cout <<a<<endl;
}
system("pause");
return 0;
}
Bạn đang đọc truyện trên: AzTruyen.Top