online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include <vector> #include <algorithm> #include <sstream> #include <fstream> int main() { std::vector<int> v; { std::ifstream file{"input.txt"}; if(int x{}; file>>x) { //введённое число раскладываем на цифры в виде массива //(младший разряд младший индекс) for(int t = x; t; t /= 10) { v.push_back(t % 10); } } } //сюда будет производиться вывод std::stringstream ss; //распечатываем массив for(auto i:v)ss<<i<<','; ss<<'\n'; //для каждого элемента массива проверяем, //что все последующие элементы - больше bool wrong{}; for (auto it = v.crbegin(); it != v.crend(); ++it) { if (std::any_of(it + 1, v.crend(), [&ss,l=*it](auto& r){ss<<"r=="<<r<<'\n'; return l<r;})) { //обнаружен неправильный порядок wrong=true; break; } } if(wrong) { ss << "not OK: " << '\n'; } else { ss << "OK: " << '\n'; } ss << '\n'; //вывод в консоль и в файл std::cout<<ss.str(); std::ofstream{"output.txt"}<<ss.str(); return 0; }
98765

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue