Задача 4 Range
Здравейте,
Мъчих се много с тази задача , но не усях да намеря решение.
Условие:
https://judge.softuni.bg/Contests/Compete/Index/1153#3
Мойто решение:
// Exercises_Range.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<sstream>
int main()
{
std::cout << "Hello World!\n";
std::vector<std::pair<int, int> >numbers;
int number = 0;
std::string line;
std::vector <int> vec;
int firstnumber = 0;
int secondnumber = 0;
while (std::getline(std::cin, line) && line != ".") {
std::istringstream ss(line);
ss >> firstnumber;
ss >> secondnumber;
numbers.push_back(std::pair<int, int>(firstnumber, secondnumber));
}
std::string input;
bool in = false;
bool out = false;
while (std::getline(std::cin, input) && input != ".") {
std::istringstream ss2(input);
ss2 >> number;
//тук не мога да разбера как да ги извеждам поотделно
for (auto p : numbers) {
if (number > p.first && number < p.second) {
std::cout << "in";
}
else if (number < p.first || number > p.second) {
std::cout << " out";
}
}
}
return 0;
}