Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. #include<math.h>
  5. using namespace std;
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12. int funkcia08(int f08[13], int i, int polePrem[13])
  13. {
  14.  
  15. srand((unsigned)time(0));
  16. for(i=0; i<13; i++)
  17. {
  18. f08[i] = (rand()%10);
  19. }
  20. for(i=0; i<13; i++)
  21. {
  22. cout << f08[i] << " ";
  23. }
  24. cout <<endl;
  25.  
  26. cout << "Funkcia, ktora scita kazde druhe prvocislo do M, zadaj M: ";
  27. int M;
  28. cin >> M;
  29. int zv;
  30.  
  31. for(i = 0; i < M; i++)
  32. {
  33. int p = 0;
  34. for (int b = 1; b <= f08[i]; b++)
  35. {
  36. zv = f08[i] % b;
  37. if (zv == 0)
  38. {
  39. p++;
  40. }
  41. }
  42. int prem;
  43. if (p == 2)
  44. {
  45. cout << "ano je prvocislo" <<endl;
  46. for(prem = 0; prem < M; prem++)
  47. {
  48. polePrem[prem] = f08[prem];
  49. }
  50. cout << polePrem[prem] << "**";
  51.  
  52. }
  53. else
  54. {
  55. cout << "nie nie nie" <<endl;
  56. }
  57. }
  58.  
  59. return 0;
  60. }
  61.  
  62.  
  63. int main()
  64. {
  65. int f08[13];
  66. int polePrem[13];
  67. int i=0;
  68.  
  69.  
  70.  
  71. funkcia08(f08,i, polePrem);
  72.  
  73. system("Pause");
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement