Les Snippets

Connexion

Connaître le signe astrologique

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 28/09/2011 17:51:12 et initié par buno [Liste]
Vue : 1730
Catégorie(s) : Date & Heure
Langages dispo pour ce code :
- C
- Python



Langage : C
Date ajout : 28/09/2011
Posté par buno [Liste]

char* getAstrologicalSign(int day, int month)
{
	// astrological signs
	static char* signs[12] = {"Capricorn","Aquarius","Pisces","Aries",
					"Taurus","Gemini","Cancer","Leo",
					"Virgo","Libra","Scorpio","Sagittarius"};


	// transition day in the month
	static int dayTransition[12] = {20,18,20,19,20,21,22,22,22,23,22,21};


	// compute the index of the astrological sign
	// be careful: do not be confused between array index and month index
	int index = day <= dayTransition[month-1] ? (month-1)%12 : month%12;


	return signs[index];
}



Remarque :
printf("%s",getAstrologicalSign(13,10)); // résultat: Libra (pour le 13 octobre)
Langage : Python
Date ajout : 21/10/2011
Posté par 0x586e [Liste]
def getAstrologicalSign(day,month):
    signs = ["Capricorn","Aquarius","Pisces","Aries","Taurus","Gemini","Cancer","Leo","Virgo","Libra","Scorpio","Sagittarius"];
    dayTransition = [20,18,20,19,20,21,22,22,22,23,22,21];
    index = (month-1)%12 if day <= dayTransition[month-1] else month%12;
    return signs[index];
Remarque :
print(getAstrologicalSign(13,10));
# returnera Libra



Codes sources en rapport avec : Zodiaque, Astrologique

{Javascript / DHTML} DONNE VOTRE SIGNE DU ZODIAQUE, CHINOIS ET AMÉRINDIEN
Bonjour, Voila une petite source « jsp » sans aucune prétention… Sa donne juste le signe du zodia...

{PHP} SIGNE DU ZODIAQUE
Voici une petite fonction permettant de connaitre le signe astrologique du mois en cours. Cela est ...

{JAVA / J2EE} SAINT SEIYA GAME 2
voici la suite du jeu Saint Seiya Game ... encore meilleur (a mon gout) que le premier du nom pour...

{JAVA / J2EE} SAINT SEIYA GAME (JEUX SUR SAINT SEIYA)
certain d'entre vous ne connaissent pas Saint Seiya... mais il ont certainement dut entendre parler ...

{Visual Basic, VB6, VB.NET, VB 2005} GRÂCE À UNE DATE : NOMBRES DE JOURS PASSÉS DEPUIS CETTE DATE, SIGNE DU ZODIAQUE, JOUR DE LA SEMAINE (LUNDI...)
Ce code sert à savoir, rien qu'en indiquant une date : le nombre de jours passés depuis cette date j...