fork download
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <cmath>
  4. #include <vector>
  5. using namespace std ;
  6. int i;
  7. int Nr=1;
  8. int pzz=0;
  9. int vfz=0;
  10. int grenze=1000;
  11. int schritt=30;
  12.  
  13. struct Eintrag
  14. {
  15. explicit Eintrag(int Nr_, int x_, int pz_, int pzz_, int vfz_)
  16. : Nr(Nr_), x(x_), pz(pz_), pzz(pzz_), vfz(vfz_)
  17. {}
  18. int Nr;
  19. int x;
  20. int pz;
  21. int pzz;
  22. int vfz;
  23. };
  24.  
  25. int pz_test(int param)//Funktion selber
  26. {
  27. for (i = 2; i < param; i++)
  28. {
  29. if (param%i == 0)
  30. break;
  31. }
  32. if(i==param)
  33. {pzz=pzz+1; return 1;}
  34. else
  35. {vfz=vfz+1; return 2;}
  36. }
  37. int main(int argc, const char * argv[])
  38. {
  39. vector<Eintrag>werte;
  40.  
  41. for (int x=1;x<=grenze;x=x+schritt)
  42. {
  43. werte.emplace_back(Nr, x, pz_test(x), pzz, vfz);
  44. Nr++;
  45. }
  46. for (std::vector<Eintrag>::iterator it = werte.begin() ; it != werte.end(); ++it)
  47. cout << " " << it->Nr << " " << it->x << " " << it->pz << " " << it->pzz << " " << it->vfz << "\n";
  48.  
  49. return 0;
  50. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
 1 1 2 0 1
 2 31 1 1 1
 3 61 1 2 1
 4 91 2 2 2
 5 121 2 2 3
 6 151 1 3 3
 7 181 1 4 3
 8 211 1 5 3
 9 241 1 6 3
 10 271 1 7 3
 11 301 2 7 4
 12 331 1 8 4
 13 361 2 8 5
 14 391 2 8 6
 15 421 1 9 6
 16 451 2 9 7
 17 481 2 9 8
 18 511 2 9 9
 19 541 1 10 9
 20 571 1 11 9
 21 601 1 12 9
 22 631 1 13 9
 23 661 1 14 9
 24 691 1 15 9
 25 721 2 15 10
 26 751 1 16 10
 27 781 2 16 11
 28 811 1 17 11
 29 841 2 17 12
 30 871 2 17 13
 31 901 2 17 14
 32 931 2 17 15
 33 961 2 17 16
 34 991 1 18 16