Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- const int sz = 10;
- void generateArr(int arr[], int min, int max);
- void showArr(int arr[]);
- void inverseArr(int arr[]);
- int getNumsSimple(int arr[]);
- bool isSimple(int val);
- int getChet(int arr[]);
- int summ(int a1, int a2) {
- cout << "First" << endl;
- return a1 + a2;
- }
- int summ(int a1, int a2, int a3) {
- cout << "Second" << endl;
- return a1 + a2 + a3;
- }
- int summ(char a1, int a2) {
- cout << "Any " << a1 << endl;
- return a2;
- }
- int summ(double a1, int a2) {
- cout << "Double " << a1 << endl;
- return a2;
- }
- void main() {
- cout << summ(1, 2) << endl;
- cout << "-----------\n";
- cout << summ(1, 2, 3) << endl;
- cout << "-----------\n";
- cout << summ('a', 2);
- cout << summ(1.0, 2);
- /*
- int arr[sz];
- generateArr(arr, 0, 100);
- showArr(arr);
- cout << "nus of simp: " << getNumsSimple(arr) << endl;
- cout << "nus of chet: " << getChet(arr) << endl;
- */
- //inverseArr(arr);
- //showArr(arr);
- }
- void generateArr(int arr[], int min, int max) {
- srand(time(0));
- for (int k = 0; k < sz; k++) {
- arr[k] = rand() % (max - min + 1) + min;
- }
- }
- void showArr(int arr[]) {
- for (int k = 0; k < sz; k++) {
- cout << arr[k] << " ";
- }
- cout << endl;
- }
- void inverseArr(int arr[]) {
- int buff[sz];
- for (int k = 0; k < sz; k++) {
- buff[sz - 1 - k] = arr[k];
- }
- for (int k = 0; k < sz; k++) {
- arr[k] = buff[k];
- }
- }
- int getNumsSimple(int arr[]) {
- int count = 0;
- for (int k = 0; k < sz; k++) {
- if (isSimple(arr[k])) {
- count++;
- }
- }
- return count;
- }
- bool isSimple(int val) {
- for (int k = 2; k < val / 2; k++) {
- if ((val % k) == 0)
- return false;
- }
- return true;
- }
- int getChet(int arr[]) {
- int count = 0;
- for (int k = 0; k < sz; k++) {
- if ((arr[k]%2) == 0) {
- count++;
- }
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement