Çözüldü C++ verilen Array'de sayıları bulma

Bu konu çözüldü olarak işaretlenmiştir. Çözülmediğini düşünüyorsanız konuyu rapor edebilirsiniz.

RSK06

Hectopat
Katılım
29 Aralık 2020
Mesajlar
2.365
Çözümler
4
Daha fazla  
Cinsiyet
Erkek
Write a C++ program to check whether the sequence of numbers 1, 2, 3 appears in a given array of integers somewhere.
Sample ınput:
{1, 1, 2, 3, 1}
{1, 1, 2, 4, 1}
{1, 1, 2, 1, 2, 3}
Sample output:
1
0
1
 
Çözüm
Kod:
#include <algorithm>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <string>
#include <vector>
#include <chrono>
#include <array>

using namespace std;

int main() {
    std::array<int, 5> arr{ 1, 1, 2, 2, 1 };
    
    if (count(arr.begin(), arr.end(), 1) && count(arr.begin(), arr.end(), 2) && count(arr.begin(), arr.end(), 3)) {
        cout << true << endl;
    }

    return 0;
}
Kod:
#include <algorithm>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <string>
#include <vector>
#include <chrono>
#include <array>

using namespace std;

int main() {
    std::array<int, 5> arr{ 1, 1, 2, 2, 1 };
    
    if (count(arr.begin(), arr.end(), 1) && count(arr.begin(), arr.end(), 2) && count(arr.begin(), arr.end(), 3)) {
        cout << true << endl;
    }

    return 0;
}
 
Çözüm
Bu siteyi kullanmak için çerezler gereklidir. Siteyi kullanmaya devam etmek için çerezleri kabul etmelisiniz. Daha Fazlasını Öğren.…