/* Disseq.c Calcola le dissequazioni di secondo grado applicando la formula risolutiva. Viene anche applicata la regola del DiCe Copyright (C) 2002 Nicola Piazzolla 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* written by kc */ #include #include main () { float risultato[2]; float delta; float ax2; float bx; float c; char pred[8]; printf("\t\t Calcolo DISSEQUAZIONI di Secondo Grado\n"); while (c!=EOF) { printf("Premere x per uscire\n"); printf("Inserire i valori di ax2+bx+c \n"); printf("\nInserire il predicato ( < > ) "); scanf("%s",&pred[0]); if(pred[0]=='x') { printf("Exit\n"); return 0; } if((pred[0]=='<') || (pred[0]=='>')) { printf("\nAx2="); scanf("%f",&ax2); fflush(stdin); printf("\nbx="); scanf("%f",&bx); fflush(stdin); printf("\nc="); scanf("%f",&c); fflush(stdin); delta=pow(bx,2)-4*(ax2*c); if (delta < 0 ) { printf("La soluzione e` sempre"); } risultato[0]= ((-bx + sqrt(delta))/(2*ax2)); risultato[1]= ((-bx - sqrt(delta))/(2*ax2)); printf("Soluzione :\n"); printf("x1 %s %f \n",pred,risultato[0]); printf("x2 %s %f \n",pred,risultato[1]); if ((ax2 < 0) && (pred[0]=='<')) printf("Le soluzioni sono Concordi Esterne (Ce) \n"); if((ax2 < 0) && (pred[0]=='>')) printf("Le soluzioni sono Discordi Interne (Di) \n"); if((ax2 > 0) && (pred[0]=='<')) printf("Le soluzioni sono Discordi Interne (Ce) \n"); if((ax2 >0) && (pred[0]=='>')) printf("Le soluzioni sono Concordi Esterne (Di) \n"); } else printf("Predicato inesistente \n" ); } }