Transformer de c++ à c
Résolu
tenohthree
Messages postés
50
Date d'inscription
Statut
Membre
Dernière intervention
-
tenohthree Messages postés 50 Date d'inscription Statut Membre Dernière intervention -
tenohthree Messages postés 50 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
comment je peut convertir un programme en c++, personnellement j'ai pas encore étudié c++, je ne sais que la programmation en C.
je cherche ici de l'aide pour le transformer en c.
voila le code:
comment je peut convertir un programme en c++, personnellement j'ai pas encore étudié c++, je ne sais que la programmation en C.
je cherche ici de l'aide pour le transformer en c.
voila le code:
#include <iostream.h> #include <stdlib.h> #include <string.h> #include <conio.h> /* La valeur de chiffre ne doit pas dépasser la plage de valeur pour unsigned int càd 4 294 967 295 , sinon il y a erreur de conversion !!! */ void ChiffreEnLettre(unsigned int, char*); int main() { unsigned int x = 0; char choix = 'o',c[256]; while((choix=='o')||(choix=='O')) { cout << "Introduire un chiffre entier : "; cin >> x; ChiffreEnLettre(x,c); cout << "\nEn lettre ca fait : "<< c <<endl; cout << "\nEncore d'autre? (O/N): "; choix = getche(); cout << "\n==================================================="<<endl; } return 0; } void ChiffreEnLettre(unsigned int chiffre, char * lettre) { unsigned int centaine, dizaine, unite, reste, y; bool dix = false; strcpy(lettre, ""); reste = chiffre; for(int i=1000000000; i>=1; i/=1000) { y = reste/i; if(y!=0) { centaine = y/100; dizaine = (y - centaine*100)/10; unite = y-(centaine*100)-(dizaine*10); switch(centaine) { case 0: break; case 1: strcat(lettre,"cent "); break; case 2: if((dizaine == 0)&&(unite == 0)) strcat(lettre,"deux cents "); else strcat(lettre,"deux cent "); break; case 3: if((dizaine == 0)&&(unite == 0)) strcat(lettre,"trois cents "); else strcat(lettre,"trois cent "); break; case 4: if((dizaine == 0)&&(unite == 0)) strcat(lettre,"quatre cents "); else strcat(lettre,"quatre cent "); break; case 5: if((dizaine == 0)&&(unite == 0)) strcat(lettre,"cinq cents "); else strcat(lettre,"cinq cent "); break; case 6: if((dizaine == 0)&&(unite == 0)) strcat(lettre,"six cents "); else strcat(lettre,"six cent "); break; case 7: if((dizaine == 0)&&(unite == 0)) strcat(lettre,"sept cents "); else strcat(lettre,"sept cent "); break; case 8: if((dizaine == 0)&&(unite == 0)) strcat(lettre,"huit cents "); else strcat(lettre,"huit cent "); break; case 9: if((dizaine == 0)&&(unite == 0)) strcat(lettre,"neuf cents "); else strcat(lettre,"neuf cent "); }// endSwitch(centaine) switch(dizaine) { case 0: break; case 1: dix = true; break; case 2: strcat(lettre,"vingt "); break; case 3: strcat(lettre,"trente "); break; case 4: strcat(lettre,"quarante "); break; case 5: strcat(lettre,"cinquante "); break; case 6: strcat(lettre,"soixante "); break; case 7: dix = true; strcat(lettre,"soixante "); break; case 8: strcat(lettre,"quatre-vingt "); break; case 9: dix = true; strcat(lettre,"quatre-vingt "); } // endSwitch(dizaine) switch(unite) { case 0: if(dix) strcat(lettre,"dix "); break; case 1: if(dix) strcat(lettre,"onze "); else strcat(lettre,"un "); break; case 2: if(dix) strcat(lettre,"douze "); else strcat(lettre,"deux "); break; case 3: if(dix) strcat(lettre,"treize "); else strcat(lettre,"trois "); break; case 4: if(dix) strcat(lettre,"quatorze "); else strcat(lettre,"quatre "); break; case 5: if(dix) strcat(lettre,"quinze "); else strcat(lettre,"cinq "); break; case 6: if(dix) strcat(lettre,"seize "); else strcat(lettre,"six "); break; case 7: if(dix) strcat(lettre,"dix-sept "); else strcat(lettre,"sept "); break; case 8: if(dix) strcat(lettre,"dix-huit "); else strcat(lettre,"huit "); break; case 9: if(dix) strcat(lettre,"dix-neuf "); else strcat(lettre,"neuf "); } // endSwitch(unite) switch (i) { case 1000000000: if(y>1) strcat(lettre,"milliards "); else strcat(lettre,"milliard "); break; case 1000000: if(y>1) strcat(lettre,"millions "); else strcat(lettre,"million "); break; case 1000: strcat(lettre,"mille "); } } // end if(y!=0) reste -= y*i; dix = false; } // end for if(strlen(lettre)==0) strcpy(lettre,"zero"); }
A voir également:
- Transformer de c++ à c
- Transformer majuscule en minuscule word - Guide
- Transformer une image en icone - Guide
- Transformer epub en kindle - Guide
- Transformer clavier qwerty en azerty - Guide
- Transformer kindle en epub - Guide