Определить, находится ли число k в массиве M состоящем из 50 целых чисел. (c++)
Пожалуйста, помогите написать программу. Буду очень благодарен. Заранее спасибо!
Другие языки программирования и технологии
Программирование на c++
#include <iostream>
#include <array>
#include <random>
#include <algorithm>
#include <iomanip>
using namespace std;
using array_50 = array<int, 50U>;
void fill(array_50& box) {
const uniform_int_distribution<> uid(1, 999);
random_device rd;
mt19937 gen(rd());
for (auto &item : box) item = uid(gen);
}
void show(const array_50& box) {
for (const auto value : box) cout << setw(4U) << value;
cout.put('\n');
}
bool find(const array_50& box, const int value) {
auto res = find(box.begin(), box.end(), value);
return res != box.end();
}
int main() {
array_50 box;
fill(box);
show(box);
cout << "Value: ";
int value;
cin >> value;
if (find(box, value)) cout << "Yes!";
else cout << "No!";
cout.put('\n');
system("pause");
}
#include <array>
#include <random>
#include <algorithm>
#include <iomanip>
using namespace std;
using array_50 = array<int, 50U>;
void fill(array_50& box) {
const uniform_int_distribution<> uid(1, 999);
random_device rd;
mt19937 gen(rd());
for (auto &item : box) item = uid(gen);
}
void show(const array_50& box) {
for (const auto value : box) cout << setw(4U) << value;
cout.put('\n');
}
bool find(const array_50& box, const int value) {
auto res = find(box.begin(), box.end(), value);
return res != box.end();
}
int main() {
array_50 box;
fill(box);
show(box);
cout << "Value: ";
int value;
cin >> value;
if (find(box, value)) cout << "Yes!";
else cout << "No!";
cout.put('\n');
system("pause");
}
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
using namespace std;
int main(){
srand(time(NULL));
int k, m[50];
bool f = false;
cout << "k = ", cin >> k;
for (int i = 0; i < 50; m[i] = rand() % 51, cout << setw(3) << m[i], m[i] == k? f = true : f = f,++i);
cout << endl << (f ? "Yes" : "No") << endl;
cin.ignore(), cin.get();
return 0;
}
#include <ctime>
#include <iomanip>
#include <iostream>
using namespace std;
int main(){
srand(time(NULL));
int k, m[50];
bool f = false;
cout << "k = ", cin >> k;
for (int i = 0; i < 50; m[i] = rand() % 51, cout << setw(3) << m[i], m[i] == k? f = true : f = f,++i);
cout << endl << (f ? "Yes" : "No") << endl;
cin.ignore(), cin.get();
return 0;
}
Тахир Рузиев
Большое спасибо!) Очень помогли!!!
if( k == M[ индекс ] ){
находится;
break;
}
находится;
break;
}
for LEL=1 TO 50 DO if integer k is in array M then CAKE
PS:CAKE LIES!
PS:CAKE LIES!
Похожие вопросы
- Подскажите с чего лучше начать изучение программирования на C#?
- Какую выбрать среду программирования для C++/Visual C++ для учебных целей кроме CodeGear Delphi+C++ Builder?
- Задача по программированию на C++ C++ C++ C++, не на Pascal
- какой язык программирования выбрать C# или С++
- Помогите решить тут нужно умение строить цикл, чего я еще не умею. . Программирование на C#
- Помогите в программирование на c++. Начало обучения
- Визуальное программирование в C++
- Начинание программирования на C++
- Где используются языки программирования Java, C#, C++, Ruby, PhP, Python и JavaScript?
- как думаете,стоит начинать учится программированию на c++??у меня друг-компьютерщик сказал что он начал и закончил.