Advertisement
marongiuchristian93

C++ | Calcolo Delta

Mar 6th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. [ Utilizzando Visual C++ Express Edition 2008 ]
  2.  
  3. ### stdafx.h
  4.  
  5. // stdafx.h : include file for standard system include files,
  6. // or project specific include files that are used frequently, but
  7. // are changed infrequently
  8.  
  9. #pragma once
  10.  
  11. // TODO: reference additional headers your program requires here
  12.  
  13. #include <stdio.h>
  14. #include <iostream>
  15. #include <math.h>
  16.  
  17. ### CalcoloDelta.cpp
  18.  
  19. // CalcoloDelta.cpp : main project file.
  20.  
  21. #include "stdafx.h"
  22.  
  23. using namespace std;
  24. using namespace System;
  25. int main() {
  26. INIZIO:
  27.     float a; float b; float c;
  28.     cout << "CALCOLO DEL DELTA\n" << endl;
  29.         // V b^2 - 4ac
  30.     cout << "Inserisci A: ";
  31.     cin >> a;
  32.     cout << "Inserisci B: ";
  33.     cin >> b;
  34.     cout << "Inserisci C: ";
  35.     cin >> c;
  36.     float ris; 
  37.     cout << "\n\nValori inseriti: " << endl;
  38.     cout << "A: " << a << "\nB: " << b << "\nC: " << c << endl;
  39.     b = pow(b,2);
  40.     cout << "\nB^2: " << b << endl;
  41.     ris = (b - (4 * a * c));
  42.     cout << "\nb^2 - (4 * a * c) = " << "\n= " << b << " - (4 * " << a << " * " << c << ") = " << "\n= " << ris << endl;
  43.     if(ris < 0) { cout << "\nDelta negativo" <<endl; }     
  44.     if(ris > 0) { cout << "\nDelta positivo" << endl; }
  45.     if(ris == 0) { cout << "\nDelta uguale a zero" << endl; }  
  46.  
  47. CHIUDI:
  48.     cout << "\nInserisci Y per ricominciare, oppure N per chiudere. Poi premi Invio." << endl;
  49.     String^ t;
  50.     t = Console::ReadLine();   
  51.     if(t == "N" || t == "n") {
  52.         exit;
  53.     }
  54.     else if(t == "Y" || t == "y") {
  55.         cout << "\n\nRicominciamo...\n\n";
  56.         goto INIZIO;
  57.     }
  58.     else {
  59.         cout << "\nValore non riconosciuto" << endl;
  60.         goto CHIUDI;
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement