Cod sursa(job #2970453)

Utilizator ioan_bogioan bogdan ioan_bog Data 25 ianuarie 2023 10:26:51
Problema Arbore partial de cost minim Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.59 kb
#include <fstream>

using namespace std;
ifstream f("elf.in");
ofstream g("elf.out");
int anterior, postanterior, current, urmator;
int main(){
    int a;
    bool ok=0;
    f>>postanterior>>anterior;
    while(f>>current){
        if(postanterior<current){
           f>>a;
           if(a>10)a=0;
           postanterior=current;
           anterior=a;
           ok=1;
        }
        else{
            g<<postanterior;
            postanterior=anterior;
            anterior=current;
        }
    }

    if(ok){
        g<<postanterior<<anterior;
    }
    g<<endl;
}