Accueil > Forum > > > > ca parait difficile besoin d'aide svp
ca parait difficile besoin d'aide svp
vendredi 2 mai 2008 à 14:14:34 |
ca parait difficile besoin d'aide svp

gersen
|
bonjour a vous voila j'ai besoin d'aide j'ai un pt'it probleme avec mon programme mon programme consiste a chercher d'abord un chemins entre 2 stations a et b ensuite chercher tous les chemins entre ces deux meme stations. on a notre reseau d'arc qui est dans un fichiers d'arc qui contient notre reseau d'arc voici le code
#include<stdio.h> #include<stdlib.h> #include<conio.h> #include<string.h> /*fonction creer station*/
typedefstructstationstation; structstation{charnom[20]; intnum; };
/*le type arc*/ typedefstructarcarc; structarc {stationstat_depart; stationstat_arriv; intindic; };
/*fonction de creation de station*/ stationcreer_station(char*nom,intnum) {stationnouv; { nouv.num=num; strcpy(nouv.nom,nom); } } /*fonctions de comparaison entre 2 stations*/ intmeme_station(stationa,stationb) { if(strcmp(a.nom,b.nom)==0&&a.num==b.num)return(1); elsereturn(0); }
/*fonctions de creation d'un arc*/
arccreer_ar(stationa,stationb,intindicateur) {arcnouv; {nouv.stat_depart=a; nouv.stat_arriv=b; nouv.indic=indicateur; } return(nouv); }
/* appartenance*/ intappartient(stationa,arcc) { if((strcmp(c.stat_depart.nom,a.nom)==0)&&(c.stat_depart.num==a.num))return(1); elseif((strcmp(c.stat_arriv.nom,a.nom)==0)&&(c.stat_arriv.num==a.num))return(1); elsereturn(0); }
/*comparaisons de 2 arc*/ intmemearc(arcc1,arcc2) { if((appartient(c1.stat_depart,c2)==1)&&(appartient(c1.stat_arriv,c2)==1))return(1); elsereturn(0);
}
/*fonctions se suivent*/ intsesuivent(arcc1,arcc2) { if((memearc(c1,c2)==0)&&(strcmp(c1.stat_arriv.nom,c2.stat_depart.nom)!=0))return(1);
elsereturn(0); }
/* PARTIE 3*/
FILE*creerReseau(intnbr) {inti=1;arca;FILE*fich; fich=fopen("tp2.dat","w"); if(fich==NULL){printf("erreur d'ouverture");exit(-1);} while(i<=nbr) { printf("donner le nom de votre station de depart de l'arc Numero %d\n",i); scanf("%s",&a.stat_depart.nom); printf("donner le nom de votre station d'arrive de l'arc Numero %d\n",i); scanf("%s",&a.stat_arriv.nom); fwrite(&a,sizeof(arc),1,fich); i++; } fclose(fich); return(fich); }
/*rechercher un arc*/
intrechercheArc(stationdepart,stationarrive,FILE*p) {arca; p=fopen("tp2.dat","r"); if(p==NULL){printf("erreur d'ouverture");exit(-1);} while(!feof(p)) {fread(&a,sizeof(arc),1,p); if((appartient(depart,a)==1)&&(appartient(arrive,a)==1))return(1); } return(0); } /*copier 2 arc*/ arccopier(arca) {arcb; strcpy(b.stat_depart.nom,a.stat_depart.nom); b.stat_depart.num=a.stat_depart.num; b.stat_arriv.num=a.stat_arriv.num; strcpy(b.stat_arriv.nom,b.stat_arriv.nom);
} /*suppression d'un ARC*/
/* rechercher l'existance d'un chemin*/
arc*recherche(stationa,stationb,FILE*p) {arcc,save,tab[50];inttrouv=0,fin,i=0; p=fopen("tp2.dat","r"); while((trouv==0)&&(!feof(p))) {fread(&c,sizeof(arc),1,p); if((appartient(a,c)==1)&&(strcmp(a.nom,c.stat_depart.nom)==0)){trouv=1; save=c; trouv=1;
rewind(p); }
} if(trouv==0){return(0);}
while((!feof(p))&&(appartient(b,c)==0)) {fread(&c,sizeof(arc),1,p); if((memearc(c,save)==0)&&(sesuivent(save,c)==1)){save=c; rewind(p); tab[i]=save; i++; } } fclose(p); return(tab); }
main() {intnbr,i;FILE*fichier;arc*s,d;stationdepart,arrive;
printf("DONNEZ LE NOMBRE D'ARC DU RESEAU \n"); scanf("%d",&nbr); fichier=creerReseau(nbr); printf("QUELLE SONT LES STATIONS QUE VOUS VOULEZ CHERCHER LE CHEMINS ENTRE ELLES\n"); printf("STATION DE DEPART:"); scanf("%s",&depart.nom); printf("STATION D'ARRIVE:"); scanf("%s",&arrive.nom); fclose(fichier); s=recherche(depart,arrive,fichier); i=0; while(i<nbr) {printf("%s %s \n",s[i].stat_depart.nom,s[i].stat_arriv.nom); i++; } getch(); }
|
|
Cette discussion est classée dans : num, stat, depart, arc, arriv
Répondre à ce message
Sujets en rapport avec ce message
BESOIN D'AIDE [ par gersen ]
bonjour a vous voila j'ai besoin d'aide j'ai un pt'it probleme avec mon programme mon programme consiste a chercher d'abord un chemins entre 2 station
Mediane d'une suite de nombres [ par alexey27 ]
Bonsoir je dois creer un programme qui affiche la mediane d'une suite de 10 nombres. Voici ce que j'ai fait : #include int main (){ const in
exercice unix [ par mohamedch123 ]
svp c'est tres urgent aidez moi pour resoudre cet exercice :écrire un programme shell STAT_FIC recevant quatre paramétres dont le premier correspond a
C/openMP [ par opiumwafa ]
Bonjour , je souhaite tester c programme sur visual studio 2008 avec C/openMP (sous Win 32 console) mais je rencontre le message d'erreur suivant : f
héritage c++ [ par mouadsa ]
Bonsoir, Alors, j'ai créer un programme en c++ concernant une classe "compte" où je px calculer le versement et le retrait bien sur sous condition. Ma
base de donnée oracle 10g [ par sancha ]
salut...jé crée 1 base de donnée sous oracle 10g et je sé ps est ce kilé correcte ou pas?vous pouvez médé?voici mon base de donnée: create table
acces et builder c++ [ par mohamedinfo ]
Bonjour, j'ai un petit pb avec bordland C++ builder 6. Je suis en train de fair : "géstion d'une mini systeme bancaire"j utilise les base de donne a
Aide sur les classes [ par mouadsa ]
Bonsoir, J'ai un programmes en c++ où je dois créer une classe compte et puis créer n comptes (tableau dynamique), les afficher tous et saisir leurs p
Livres en rapport
|
Derniers Blogs
[WP7] DYNAMICALLY CHANGE STARTUP PAGE[WP7] DYNAMICALLY CHANGE STARTUP PAGE par KooKiz
Let's say that you want to allow the user to customize the startup page of your application. You can easily change the startup page by editing the 'NavigationPage' attribute in the manifest file. But the manifest cannot be modified once the applicatio...
Cliquez pour lire la suite de l'article par KooKiz SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|