Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cmath>
  4. using namespace std;
  5. int foo1 (int *m)
  6. {
  7. srand(time(NULL));
  8. for(int i = 0; i < 10; i++)
  9. {
  10. m[i]=rand()%100;
  11. cout<<m[i]<<" ";
  12. }
  13. cout <<endl;
  14. return 0;
  15. }
  16. int foo2 (int *m)
  17. {
  18. cout << "vvedite elementi massiva : " << endl;
  19. for(int i=0; i<10;i++)
  20. {
  21. cin >> m[i];
  22. }
  23. for(int i=0; i<10;i++)
  24. {
  25. cout<<m[i]<<" ";
  26. }
  27. cout <<endl;
  28. return 0;
  29. }
  30. int main ( )
  31. {
  32. int sum = 0;
  33. const int k =10;
  34. int m[k];
  35. int a;
  36. cout << "viberete sposob zapolneniya : 1 - randomno, 2 - vvod s klav, 3 - massiv is koda" << endl;
  37. cin >> a;
  38. if (a==1)
  39. foo1(m);
  40. if (a == 2)
  41. foo2(m);
  42. if (a == 3)
  43. {
  44. int m[k] = {0, 1, 2, 3, 25, 4, 6, 7, 8, 75};
  45. for(int i=0; i<k;i++)
  46. {
  47. if ( (m[i] % 5 == 0) && (sqrt(i) * sqrt(i) == i))
  48. {
  49. cout << "element " << i << " = " << m[i] << endl;
  50. sum += m[i];
  51. }
  52. }
  53. cout << "Summa : " << sum << endl;
  54. return 0;
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement