Probleme avec mon code
beny100
Messages postés
213
Date d'inscription
vendredi 17 novembre 2006
Statut
Membre
Dernière intervention
1 avril 2009
-
12 sept. 2007 à 04:01
cs_juju12
Messages postés
966
Date d'inscription
samedi 3 avril 2004
Statut
Membre
Dernière intervention
4 mars 2010
-
12 sept. 2007 à 11:54
bonjour a tous voici mon code
#include <stdlib.h>
#include <stdlib.h>
#include <math.h>
#define Pi 3.1415926535
#include <dos.h>
#include <windows.h>
#include <gtk/gtk.h>
GtkWidget *fenetre;
GtkWidget *vc;
GtkWidget *hc1;
GtkWidget *hc2;
GtkWidget *hc3;
GtkWidget *hc4;
GtkWidget *hc5;
GtkWidget *txt1;
GtkWidget *txt2;
GtkWidget *txt3;
GtkWidget *txt4;
GtkWidget *lbl1;
GtkWidget *lbl2;
GtkWidget *lbl3;
GtkWidget *lbl4;
GtkWidget *btn;
void calculer(void)
{
unsigned long r,x;//Déclaration des constantes//
r = 6378;
x= 35786;
float dl,val1,val2,Az,As,t2;
//unsigned long Ret = pow(35786, 2);
float fact=0,t1=0;
float i,gf,k,l;
gint somme;
gchar temp[40],resul[40];
t1=atoi(gtk_entry_get_text(GTK_ENTRY(txt1)));
while((t1<=0)||(t1>180))
{
if (t1<=0)
{
void Menu1(void) // afficher une information en cas de valeur negative
{
MessageBox (NULL, "Information", "Signification", MB_ICONINFORMATION);
}
}
else { }
}
t2=atoi(gtk_entry_get_text(GTK_ENTRY(txt2)));
dl=sqrt((x*x)+2*r*(r+x)*(1-cos(t1*(Pi/180))*cos(t2*(Pi/180))));
val1=((r+x)/dl)*sqrt((1-(cos(t1*(Pi/180)))*cos(t1*(Pi/180))*(cos(t2*(Pi/180))*cos(t2*(Pi/180)))));
val2=sin(t2*(Pi/180))/(sqrt((1-(cos(t1*(Pi/180)))*cos(t1*(Pi/180))*(cos(t2*(Pi/180))*cos(t2*(Pi/180))))));
Az=asin(val2)*(180/Pi);
As=acos(val1)*(180/Pi);
//somme=t1+t2;
sprintf (temp,"%10f",As);
sprintf (resul,"%10f",Az);
gtk_entry_set_text(txt3,temp);
gtk_entry_set_text(txt4,resul);
}
int main(int argc, char **argv)
{
gtk_init(&argc, &argv);
/* Création de la fenetre */
fenetre = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(fenetre), "SOMME");
gtk_window_set_default_size(GTK_WINDOW(fenetre), 320, 200);
g_signal_connect(G_OBJECT(fenetre), "destroy", G_CALLBACK(gtk_main_quit),NULL);
vc=gtk_vbox_new(TRUE,0);
hc1=gtk_hbox_new(TRUE,5);
hc2=gtk_hbox_new(TRUE,5);
hc3=gtk_hbox_new(TRUE,5);
hc4=gtk_hbox_new(TRUE,5);
hc5=gtk_hbox_new(TRUE,5);
gtk_container_add(GTK_CONTAINER(fenetre), vc);
gtk_box_pack_start(vc,hc1,TRUE,TRUE,5);
gtk_box_pack_start(vc,hc2,TRUE,TRUE,5);
gtk_box_pack_start(vc,hc3,TRUE,TRUE,5);
gtk_box_pack_start(vc,hc4,TRUE,TRUE,5);
gtk_box_pack_start(vc,hc5,TRUE,TRUE,5);
lbl1=gtk_label_new("Entrez la latitude de la station en dégré");
lbl2=gtk_label_new(" difference de longitude entre SAT et VSAT en dégré");
lbl3=gtk_label_new("azimut en dégré :");
lbl4=gtk_label_new("Angle de site en dégré :");
txt1=gtk_entry_new();
txt2=gtk_entry_new();
txt3=gtk_entry_new();
txt4=gtk_entry_new();
btn=gtk_button_new_with_label("Calculer");
g_signal_connect(G_OBJECT(btn), "clicked", calculer,NULL);
gtk_box_pack_start(hc1,lbl1,TRUE,TRUE,5);
gtk_box_pack_start(hc1,txt1,TRUE,TRUE,5);
gtk_box_pack_start(hc2,lbl2,TRUE,TRUE,5);
gtk_box_pack_start(hc2,txt2,TRUE,TRUE,5);
gtk_box_pack_start(hc3,btn,TRUE,TRUE,5);
gtk_box_pack_start(hc4,lbl3,TRUE,TRUE,5);
gtk_box_pack_start(hc4,txt3,TRUE,TRUE,5);
gtk_box_pack_start(hc5,lbl4,TRUE,TRUE,5);
gtk_box_pack_start(hc5,txt4,TRUE,TRUE,5);
gtk_widget_show_all(fenetre);
gtk_main();
return EXIT_SUCCESS;
}
mon probleme est que lorsque la valeur est negative mon programme ne fonctionne pas et reste planté par contre quant elle est negative je voudrais qu'elle me le dise dans la condition si specifier, mais rien ne marche et je ne sais plus ou decelle l'erreur.
aidez moi s'il vous plaît