GerexD

gy13_13,14,15

Jan 16th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. 13
  2.  
  3.  
  4. #include <iostream>
  5. #include <cmath>
  6. //Írjuk ki az összes ikerprímet, amely egy adott n értéknél kisebb!
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12. int n,i,c,d,b,e;
  13.  
  14. cin>>n;
  15.  
  16. for(i=1;i<=n;i++){
  17. c=1;
  18. d=1;
  19. for(b=2;b<=sqrt(i);b++)
  20. if(i%b==0) c=0;
  21. for(e=2;e<=sqrt(i+2);e++)
  22. if((i+2)%e==0) d=0;
  23. if(c==1 && d==1)
  24. cout<<i<<"---"<<i+2<<endl;}
  25.  
  26. return 0;
  27. }
  28. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  29.  
  30. 14
  31.  
  32. #include <iostream>
  33. #include <cmath>
  34. //14. Határozzuk meg egy szám prímosztóinak összegét!
  35.  
  36.  
  37. using namespace std;
  38.  
  39. int main()
  40. {
  41. int a,b,c,d,e=0;
  42. cin>>a;
  43.  
  44. for(b=2;b<=(a/2);b++){
  45. d=1;
  46. for(c=2;c<=sqrt(b);c++)
  47. if(b%c==0) d=0;
  48. if(a%b==0 && d==1)
  49. e=e+b;}
  50. cout<<"A prim osztok osszege--->"<<e;
  51.  
  52.  
  53. return 0;
  54. }
  55.  
  56. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  57.  
  58. 15
  59.  
  60. #include <iostream>
  61. #include <cmath>
  62. //15. Számoljuk ki az olyan háromjegyű prímek összegét, amelyeknek fordítottja is prim.
  63. using namespace std;
  64.  
  65. int main()
  66. {
  67. int a,c,d,g,h,i,x=0;
  68.  
  69. for(a=100;a<=999;a++){
  70. g=1;
  71. i=1;
  72. d=a%10*100+a/10%10*10+a/100;
  73.  
  74. for(c=2;c<=sqrt(a);c++){
  75.  
  76. if(a%c==0)
  77. g=0;}
  78.  
  79. for(h=2;h<=sqrt(d);h++){
  80. if(d%h==0)
  81. i=0;}
  82. if(g==1 && i==1)
  83. x=x+a;
  84. cout<<a<<endl;}
  85. cout<<"3jegyu primek osszege, melyek forditottja is prim--->"<<x;
  86.  
  87.  
  88. return 0;
  89. }
  90. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Advertisement
Add Comment
Please, Sign In to add comment