Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <time.h>
- #include <stdlib.h>
- using namespace std;
- void Init(int *mas, int size);
- void Print(int *mas, int size);
- int Funk(int *mas, int size, int value);
- int _tmain(int argc, _TCHAR* argv[])
- {
- setlocale(LC_ALL, "Russian");
- int size = 10;
- int *mas = new int[size];
- Init(mas, size);
- Print(mas, size);
- int value;
- cout << "Введите число -> ";
- cin >> value;
- cout << "Результат " << Funk(mas, size, value) << endl;
- }
- void Init(int *mas, int size)
- {
- for (int i = 0; i < size; *mas++ = rand() % 20 + -6, i++);
- }
- void Print(int *mas, int size)
- {
- cout << "Массив" << endl;
- for (int i = 0; i < size; cout << *mas++ << " ", i++);
- cout << endl;
- }
- int Funk(int *mas, int size, int value)
- {
- bool b = false;
- for (int i = 0; i < size; i++)
- {
- if (*(mas + i) == value)
- {
- b = true;
- return *(mas + i);
- break;
- }
- }
- if (b == false)
- {
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement