Afficher les signes de zordiaque en C
Résolu
fati56
Messages postés
24
Date d'inscription
Statut
Membre
Dernière intervention
-
fati56 Messages postés 24 Date d'inscription Statut Membre Dernière intervention -
fati56 Messages postés 24 Date d'inscription Statut Membre Dernière intervention -
A voir également:
- Afficher les signes de zordiaque en C
- Afficher appdata - Guide
- Afficher mot de passe wifi android - Guide
- Afficher les commentaires word - Guide
- Afficher google en page d'accueil - Guide
- Afficher taille dossier windows - Guide
8 réponses
j'ai essayer , il te reste encore 12 erreurs que je n'arrive pas a corriger..
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j;
printf("entrer votre date de naissance \n");
scanf("%d\%d",&i,&j);
if(((i>=22)&&(i<=31)&&(j=12))||((i>=1)&&(i<=20)&&(j=1)))
{
printf("votre zordiaque est capricorne\n");
else
{
if(((i>=21)&&(i<=30)&&(j=1))||((i>=1)&&(i<=19)&&(j=2)))
{
printf("votre zordiaque est verseau\n");
else
{
if(((i>=20)&&(i<=29)&&(j=2))||((i>=1)&&(i<=20)&&(j=3)))
{
printf("votre zordiaque est poissons\n");
else
{
if(((i>=21)&&(i<=31)&&(j=3))||((i>=1)&&(i<=20)&&(j=4)))
{
printf("votre zordiaque est belier\n");
else
{
if(((i>=21)&&(i<=30)&&(j=4))||((i>=1)&&(i<=20)&&(j=5)))
{
printf("votre zordiaque est taureaux\n");
else
{
if(((i>=21)&&(i<=31)&&(j=5))||((i>=1)&&(i<=21)&&(j=6)))
{
printf("votre zordiaque est gemaux\n");
else
{
if(((i>=22)&&(i<=30)&&(j=6))||((i>=1)&&(i<=21)&&(j=6)))
{
printf("votre zordiaque est cancer\n");
else
{
if(((i>=23)&&(i<=31)&&(j=7))||((i>=1)&&(i<=23)&&(j=8)))
{
printf("votre zordiaque est lion\n");
else
{
if(((i>=24)&&(i<=31)&&(j=8))||((i>=1)&&(i<=23)&&(j=9)))
{
printf("votre zordiaque est vierge\n");
else
{
if(((i>=24)&&(i<=30)&&(j=9))||((i>=1)&&(i<=23)&&(j=10)))
{
printf("votre zordiaque est balance\n");
else
{
if(((i>=24)&&(i<=31)&&(j=10))||((i>=1)&&(i<=22)&&(j=11)))
{
printf("votre zordiaque est scorpion\n");
else
{
if(((i>=23)&&(i<=30)&&(j=11))||((i>=1)&&(i<=21)&&(j=12)))
{
printf("votre zordiaque est sagitaire\n");
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
getch();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j;
printf("entrer votre date de naissance \n");
scanf("%d\%d",&i,&j);
if(((i>=22)&&(i<=31)&&(j=12))||((i>=1)&&(i<=20)&&(j=1)))
{
printf("votre zordiaque est capricorne\n");
else
{
if(((i>=21)&&(i<=30)&&(j=1))||((i>=1)&&(i<=19)&&(j=2)))
{
printf("votre zordiaque est verseau\n");
else
{
if(((i>=20)&&(i<=29)&&(j=2))||((i>=1)&&(i<=20)&&(j=3)))
{
printf("votre zordiaque est poissons\n");
else
{
if(((i>=21)&&(i<=31)&&(j=3))||((i>=1)&&(i<=20)&&(j=4)))
{
printf("votre zordiaque est belier\n");
else
{
if(((i>=21)&&(i<=30)&&(j=4))||((i>=1)&&(i<=20)&&(j=5)))
{
printf("votre zordiaque est taureaux\n");
else
{
if(((i>=21)&&(i<=31)&&(j=5))||((i>=1)&&(i<=21)&&(j=6)))
{
printf("votre zordiaque est gemaux\n");
else
{
if(((i>=22)&&(i<=30)&&(j=6))||((i>=1)&&(i<=21)&&(j=6)))
{
printf("votre zordiaque est cancer\n");
else
{
if(((i>=23)&&(i<=31)&&(j=7))||((i>=1)&&(i<=23)&&(j=8)))
{
printf("votre zordiaque est lion\n");
else
{
if(((i>=24)&&(i<=31)&&(j=8))||((i>=1)&&(i<=23)&&(j=9)))
{
printf("votre zordiaque est vierge\n");
else
{
if(((i>=24)&&(i<=30)&&(j=9))||((i>=1)&&(i<=23)&&(j=10)))
{
printf("votre zordiaque est balance\n");
else
{
if(((i>=24)&&(i<=31)&&(j=10))||((i>=1)&&(i<=22)&&(j=11)))
{
printf("votre zordiaque est scorpion\n");
else
{
if(((i>=23)&&(i<=30)&&(j=11))||((i>=1)&&(i<=21)&&(j=12)))
{
printf("votre zordiaque est sagitaire\n");
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
getch();
return 0;
}
voila une copie de mon debug si tu veux voir ou son tes erreures:
--------------------Configuration: zodiac - Win32 Debug--------------------
Compiling...
zodiac.cpp
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(8) : warning C4129: '%' : unrecognized character escape sequence
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(12) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(17) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(22) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(27) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(32) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(37) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(42) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(47) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(52) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(57) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(62) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(89) : error C2065: 'getch' : undeclared identifier
Error executing cl.exe.
zodiac.obj - 12 error(s), 1 warning(s)
--------------------Configuration: zodiac - Win32 Debug--------------------
Compiling...
zodiac.cpp
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(8) : warning C4129: '%' : unrecognized character escape sequence
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(12) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(17) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(22) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(27) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(32) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(37) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(42) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(47) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(52) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(57) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(62) : error C2181: illegal else without matching if
C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\zodiac.cpp(89) : error C2065: 'getch' : undeclared identifier
Error executing cl.exe.
zodiac.obj - 12 error(s), 1 warning(s)
Si cela peut t'intéresser j'ai fait un peu le même TP en cours de DAIGL mais en C#,et cela marche super bien!
voici mon code,si tu t'y connais en c#,par contre tout en bas je t'ai mis en gras le chemin d'accès que moi j'ai mis mais bien sure si tu fais ce programme sur ton pc il faudra que tu mette le chemin d'accès correspondant:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Signe_du_zodiaque
{
public partial class Form1 : Form
{
string Mois;
string Jour;
const int NbMois = 12;
string[] Tsignes = new string[] { "", "VERSEAU", "POISSONS", "BELIER", "TAUREAU", "GEMEAUX", "CANCER", "LION", "VIERGE", "BALANCE", "SCORPIOIN", "SAGITTAIRE", "CAPRICORNE" };
int[] TJourdebut = new int[] { 0, 19, 18, 20, 19, 20, 20, 22, 22, 22, 22, 21, 21 };
string[] Timages = new string[] { "", "VERSEAU.jpg", "POISSON.jpg", "BELIER.jpg", "TAUREAU.jpg", "GEMEAUX.jpg", "CANCER.jpg", "LION.jpg", "VIERGE.jpg", "BALANCE.jpg", "SCORPION.jpg", "SAGITTAIRE.jpg", "CAPRICORNE.jpg" };
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
txtMois.Text = hslMois.Minimum.ToString();
txtJour.Text = hslJour.Minimum.ToString();
}
private void btnQuitter_Click(object sender, EventArgs e)
{
this.Close();
}
private void hslJour_Scroll(object sender, ScrollEventArgs e)
{
txtJour.Text = hslJour.Value.ToString();
}
private void hslMois_Scroll(object sender, ScrollEventArgs e)
{
txtMois.Text = hslMois.Value.ToString();
}
private void btnSigne_Click(object sender, EventArgs e)
{
Jour = txtJour.Text;
Mois = txtMois.Text;
txtSigne.Text = Fzodiaque(int.Parse(Jour), int.Parse(Mois));
}
private string Fzodiaque(int Jour, int Mois)
{
if (Jour < TJourdebut[Mois])
{
if (Mois == 1)
{
Mois = 12;
}
else
{
Mois--;
}
}
imgSigne.Image = Image.FromFile(@"C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\Topaze DAIGL\Signe du zodiaque\Images des signes de zodiaque\" + Timages[Mois]);
return (Tsignes[Mois]);
}
}
}
voici mon code,si tu t'y connais en c#,par contre tout en bas je t'ai mis en gras le chemin d'accès que moi j'ai mis mais bien sure si tu fais ce programme sur ton pc il faudra que tu mette le chemin d'accès correspondant:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Signe_du_zodiaque
{
public partial class Form1 : Form
{
string Mois;
string Jour;
const int NbMois = 12;
string[] Tsignes = new string[] { "", "VERSEAU", "POISSONS", "BELIER", "TAUREAU", "GEMEAUX", "CANCER", "LION", "VIERGE", "BALANCE", "SCORPIOIN", "SAGITTAIRE", "CAPRICORNE" };
int[] TJourdebut = new int[] { 0, 19, 18, 20, 19, 20, 20, 22, 22, 22, 22, 21, 21 };
string[] Timages = new string[] { "", "VERSEAU.jpg", "POISSON.jpg", "BELIER.jpg", "TAUREAU.jpg", "GEMEAUX.jpg", "CANCER.jpg", "LION.jpg", "VIERGE.jpg", "BALANCE.jpg", "SCORPION.jpg", "SAGITTAIRE.jpg", "CAPRICORNE.jpg" };
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
txtMois.Text = hslMois.Minimum.ToString();
txtJour.Text = hslJour.Minimum.ToString();
}
private void btnQuitter_Click(object sender, EventArgs e)
{
this.Close();
}
private void hslJour_Scroll(object sender, ScrollEventArgs e)
{
txtJour.Text = hslJour.Value.ToString();
}
private void hslMois_Scroll(object sender, ScrollEventArgs e)
{
txtMois.Text = hslMois.Value.ToString();
}
private void btnSigne_Click(object sender, EventArgs e)
{
Jour = txtJour.Text;
Mois = txtMois.Text;
txtSigne.Text = Fzodiaque(int.Parse(Jour), int.Parse(Mois));
}
private string Fzodiaque(int Jour, int Mois)
{
if (Jour < TJourdebut[Mois])
{
if (Mois == 1)
{
Mois = 12;
}
else
{
Mois--;
}
}
imgSigne.Image = Image.FromFile(@"C:\Documents and Settings\topaze\Bureau\BTS INFO perso\DAIGL\Topaze DAIGL\Signe du zodiaque\Images des signes de zodiaque\" + Timages[Mois]);
return (Tsignes[Mois]);
}
}
}
Bonjour,
Ton scanf est malade...
Le \ est le 'escape character' en C. Il s'attend donc à obtenir une saisie du type "27%d"
Le caractère \ s'écrit \\ en C.
Je trouve que les 12 if sont un peu lourd...
M.
Ton scanf est malade...
Le \ est le 'escape character' en C. Il s'attend donc à obtenir une saisie du type "27%d"
Le caractère \ s'écrit \\ en C.
Je trouve que les 12 if sont un peu lourd...
#include <stdio.h> #include <stdlib.h> typedef struct { unsigned int day; unsigned int month; char *szSign; } Sign; Sign g_aSigns[] = { { 20, 1, "Capricorne" }, { 18, 2, "Verseau" }, { 20, 3, "Poisson" }, { 20, 4, "Bélier" }, { 21, 5, "Taureau" }, { 21, 6, "Gémaux" }, { 22, 7, "Cancer" }, { 22, 8, "Lion" }, { 22, 9, "Vierge" }, { 22, 10, "Balance" }, { 21, 11, "Scorpion" }, { 23, 12, "Sagittaire" } }; void printSign( unsigned int day, unsigned int month) { unsigned int i; for ( i = 0 ; i != sizeof( g_aSigns ) / sizeof( Sign ) ; i++ ) { if ( ( day <= g_aSigns[i].day ) && ( month <= g_aSigns[i].month ) ) { printf( "Votre signe est %s.\n", g_aSigns[i].szSign ); return; } } printf( "Votre signe est %s\n", g_aSigns[0].szSign ); } int main() { printSign( 30, 12 ); getchar(); return 0; }
M.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Eyh!
Voila quelque chose qui marche!
merci beaucoup!! (ça m'aurait stresser que personne ne trouve la réponse ,je m'étais intéressé au sujet..)
^^
Voila quelque chose qui marche!
merci beaucoup!! (ça m'aurait stresser que personne ne trouve la réponse ,je m'étais intéressé au sujet..)
^^
Les dates ont été reprise sur le Wikipédia Fr, de mémoire certaines ne sont pas être celles que l'on trouve dans l'horoscope du Télé Z...
M.
M.
Y a quelques soucis d'accolades qui sortent tout de suite en indentant.
J'ai changé le scanf
Les if doivent être du style:
Ca évite d'indenter jusque dans le champs d'à côté
Si il y a des points pas clairs sur ma version, n'hésite pas à demander. ;-)
M.
scanf( "%d \\ %d", &i, &j ); // Les espaces ne comptent pas dans le scanf, profitons-en! if(((i>=22)&&(i<=31)&&(j=12))||((i>=1)&&(i<=20)&&(j=1))) { printf("votre zordiaque est capricorne\n"); else { ...
J'ai changé le scanf
Les if doivent être du style:
if ( truc ) { ... } else { ... } // Je fais mes else if comme ça moi: if ( truc ) { ... } else if ( machin ) { ... } else if ( bidule ) { ... } else { ... }
Ca évite d'indenter jusque dans le champs d'à côté
Si il y a des points pas clairs sur ma version, n'hésite pas à demander. ;-)
M.
Whoops,
Il y a un autre petit blême ...
en C, = est une affectation et == un opérateur d'égalité.
i prends la valeur 1, puis comme 1 est vrai le test est vrai. (toute valeurs différente de zéro est vraie)
M.
Il y a un autre petit blême ...
en C, = est une affectation et == un opérateur d'égalité.
int i = 22; if ( i = 1 ) ...
i prends la valeur 1, puis comme 1 est vrai le test est vrai. (toute valeurs différente de zéro est vraie)
M.
voila j'ai modifié et ca a marché
#include <stdio.h>
#include <stdlib.h>
main()
{
int i,j;
printf("entrer votre date de naissance j/m :\n");
scanf("%d/%d",&i,&j);
if((i>=22&&i<=30&&j==12)||(i>=1&&i<=20&&j==1))
printf("votre zordiaque est capricorne\n");
if((i>=21&&i<=31&j==1)||(i>=1&&i<=19&&j==2))
printf("votre zordiaque est verseau\n");
if((i>=20&&i<=29&&j==2)||(i>=1&&i<=20&&j==3))
printf("votre zordiaque est poissons\n");
if((i>=21&&i<=31&&j==3)||(i>=1&&i<=20&&j==4))
printf("votre zordiaque est belier\n");
if((i>=21&&i<=30&&j==4)||(i>=1&&i<=20&&j==5))
printf("votre zordiaque est taureau\n");
if((i>=21&&i<=31&&j==5)||(i>=1&&i<=21&&j==6))
printf("votre zordiaque est gemaux\n");
if((i>=22&&i<=30&&j==6)||(i>=1&&i<=22&&j==7))
printf("votre zordiaque est cancer\n");
if((i>=23&&i<=31&&j==7)||(i>=1&&i<=23&&j==8))
printf("votre zordiaque est lion\n");
if((i>=24&&i<=31&&j==8)||(i>=1&&i<=23&&j==9))
printf("votre zordiaque est vierge\n");
if((i>=24&&i<=30&&j==9)||(i>=1&&i<=23&&j==10))
printf("votre zordiaque est balance\n");
if((i>=24&&i<=31&&j==10)||(i>=1&&i<=22&&j==11))
printf("votre zordiaque est scorpion\n");
if((i>=23&&i<=30&&j==11)||(i>=1&&i<=21&&j==11))
printf("votre zordiaque est sagitaire\n");
getch();
}
merci a vous ts.
#include <stdio.h>
#include <stdlib.h>
main()
{
int i,j;
printf("entrer votre date de naissance j/m :\n");
scanf("%d/%d",&i,&j);
if((i>=22&&i<=30&&j==12)||(i>=1&&i<=20&&j==1))
printf("votre zordiaque est capricorne\n");
if((i>=21&&i<=31&j==1)||(i>=1&&i<=19&&j==2))
printf("votre zordiaque est verseau\n");
if((i>=20&&i<=29&&j==2)||(i>=1&&i<=20&&j==3))
printf("votre zordiaque est poissons\n");
if((i>=21&&i<=31&&j==3)||(i>=1&&i<=20&&j==4))
printf("votre zordiaque est belier\n");
if((i>=21&&i<=30&&j==4)||(i>=1&&i<=20&&j==5))
printf("votre zordiaque est taureau\n");
if((i>=21&&i<=31&&j==5)||(i>=1&&i<=21&&j==6))
printf("votre zordiaque est gemaux\n");
if((i>=22&&i<=30&&j==6)||(i>=1&&i<=22&&j==7))
printf("votre zordiaque est cancer\n");
if((i>=23&&i<=31&&j==7)||(i>=1&&i<=23&&j==8))
printf("votre zordiaque est lion\n");
if((i>=24&&i<=31&&j==8)||(i>=1&&i<=23&&j==9))
printf("votre zordiaque est vierge\n");
if((i>=24&&i<=30&&j==9)||(i>=1&&i<=23&&j==10))
printf("votre zordiaque est balance\n");
if((i>=24&&i<=31&&j==10)||(i>=1&&i<=22&&j==11))
printf("votre zordiaque est scorpion\n");
if((i>=23&&i<=30&&j==11)||(i>=1&&i<=21&&j==11))
printf("votre zordiaque est sagitaire\n");
getch();
}
merci a vous ts.