Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cmath>
- using namespace std;
- int foo1 (int *m)
- {
- srand(time(NULL));
- for(int i = 0; i < 10; i++)
- {
- m[i]=rand()%100;
- cout<<m[i]<<" ";
- }
- cout <<endl;
- return 0;
- }
- int foo2 (int *m)
- {
- cout << "vvedite elementi massiva : " << endl;
- for(int i=0; i<10;i++)
- {
- cin >> m[i];
- }
- for(int i=0; i<10;i++)
- {
- cout<<m[i]<<" ";
- }
- cout <<endl;
- return 0;
- }
- int main ( )
- {
- int sum = 0;
- const int k =10;
- int m[k];
- int a;
- cout << "viberete sposob zapolneniya : 1 - randomno, 2 - vvod s klav, 3 - massiv is koda" << endl;
- cin >> a;
- if (a==1)
- foo1(m);
- if (a == 2)
- foo2(m);
- if (a == 3)
- {
- int m[k] = {0, 1, 2, 3, 25, 4, 6, 7, 8, 75};
- for(int i=0; i<k;i++)
- {
- if ( (m[i] % 5 == 0) && (sqrt(i) * sqrt(i) == i))
- {
- cout << "element " << i << " = " << m[i] << endl;
- sum += m[i];
- }
- }
- cout << "Summa : " << sum << endl;
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement