Skip to content
Snippets Groups Projects

Ejemplo C++11

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Jesus Laime
    11727.cpp 1.31 KiB
    #include <bits/stdc++.h>
    #define INF 10000000
    
    using namespace std;
    
    /*
     * se tiene que tener instalado g++
     * para compilarlo: g++ -std=c++11 "filename.cpp" -o "exefile"
     * para correrlo: ./"exefile"
     */
    
    int main(){
    
    	int cases;
    	int employeeOne, employeeTwo, employeeThree;
    	int minEmployee, maxEmployee, midEmployee;
    
    	// leemos la cantidad de casos
    	std::cin >> cases;
    
    	for(int currentCase=1; currentCase <= cases; currentCase++){
    
    		// leemos los datos de los tres empleados
    		std::cin >> employeeOne >> employeeTwo >> employeeThree;
    
    		// buscamos al empleado con el sueldo mas bajo
    		minEmployee = std::min(employeeOne, employeeTwo);
    		minEmployee = std::min(minEmployee, employeeThree);
    
    		// buscamos al empleado con el sueldo mas alto
    		maxEmployee = std::max(employeeOne, employeeTwo);
    		maxEmployee = std::max(maxEmployee, employeeThree);
    
    		// buscamos al empleado del medio
    		if(employeeOne > minEmployee && employeeOne < maxEmployee)
    			midEmployee = employeeOne;
    		else if(employeeTwo > minEmployee && employeeTwo < maxEmployee)
    			midEmployee = employeeTwo;
    		else if(employeeThree > minEmployee && employeeThree < maxEmployee)
    			midEmployee = employeeThree;
    		else
    			midEmployee = employeeOne;
    
    		// imprimimos el resultado
    		std::cout << "Case " << currentCase << ": " << midEmployee << std::endl;
    	}
    
    	return 0;
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment