#include <iostream.h> # include <math.h> void main () { long i,n,a,b,c,dem1=0,dem2=0,t1=0,t2=0; cout<<"Nhap vao doan a,b,c : " ; cin>>a>>b>>c; cout<<"Cac so nguyen to doan a,b: "<<endl; for(n=a;n<=b;n++){ i=2; while(n%i!=0&&i<=sqrt(n))i++; if(i>sqrt(n)){ t1+=n; dem1++; cout<<n<<" "; }} cout<<" \ n Co "<<dem1<<" so nguyen to"<<endl; cout<<"Tong doan a,b: "<<t1<<endl; cout<<"Cac so nguyen doan b,c ;"<<endl; for(n=b;n<=c;n++){ i=2; while(n%i!=0&& i<=sqr t(n))i++; if(i>sqrt(n)) { t2+=n; dem2++; cout<<n<<" "; }} cout<<" \ n Co "<<dem2<<" so nguyen to "<<endl; cout<<"Tong doan b,c : "<<t2<<endl; if(dem1<dem2)cout<<"Doan 2 co nhieu so nguyen to hon ! "<<endl; else if(dem 1>dem2)cout<<"Doan 1 co nhieu so nguyen to hon !"<<endl; else cout<<"2 doan co so nguyen to bang nhau !"; }