Witam, jak znalezc liczbe trzycyfrowa w ciagu podana przez uzytkownika? Podaje zalozmy 5 liczb i chce zeby program napisal mi czy w ciagu jest liczba trzycyfrowa i mi ja wystwietlil. Jakies wskazowki?
0
0
Wczytaj wszystkie liczby i sprawdz, czy ktoras z nich spelnia twoj warunek np.
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <cmath>
using namespace std;
int main() {
auto cond = istream_iterator<int>{} != find_if(
istream_iterator<int>(cin), {}, [](int num) {
return to_string(abs(num)).size() == 3;
}
);
cout << cond;
return 0;
}
0
int x;
while (cin >> x) {
if (x>=100 && x<1000)
{
cout << x << endl;
break;
}
}