/*
  Copyright (C) 2013 Alessandro Bugatti (alessandro.bugatti@istruzione.it)

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*! \file
 *  \brief Calcolo della traiettoria di un raggio laser
 *  \author Alessandro Bugatti
 *  \version 0.1
 *  \date  Creazione  29/10/2013
 *  \date  Ultima modifica 29/10/2013
 *
 */

#include <stdio.h>
#include <math.h>

int main()
{
    float ACspecchio 0posizione_ottimale 0distanza
    distanza_min;
    printf("Inserisci la distanza dell'edificio P1: ");
    scanf("%f",&A);
    printf("Inserisci la distanza dell'edificio P2: ");
    scanf("%f",&B);
    printf("Inserisci la distanza tra i due edifici: ");
    scanf("%f",&C);
    distanza_min sqrt(A*A) + sqrt(C*B*B);
    while (specchio <= C)
    {
        distanza sqrt(specchio*specchio A*A) + 
            sqrt((specchio)*(C-specchio) + B*B);
        if (distanza distanza_min)
        {
            distanza_min distanza;
            posizione_ottimale specchio;
        }
        specchio += 0.1;
    }
    printf("La distanza ottimale si ha con lo specchio posizionato in %f"
        posizione_ottimale);
    return 0;