Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 9.00 KB | None | 0 0
  1. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2.                                  Bibliothèques
  3. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <windows.h>
  8. #include <myconio.h>
  9. #include <math.h>
  10.  
  11. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12.                                     Define
  13. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  14.  
  15. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  16.                                     Main
  17. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  18.  
  19. void main (void){
  20. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  21.                                     Initialisations
  22. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  23.     int ligne,colonne;
  24.     int positionX,positionY=8;
  25.     int ecrireX=45,ecrireY=11;
  26.  
  27.     char tableauNom[7][92]={"                                                                      __                   ",
  28.                             "     _____                                    _____                  |__|                  ",
  29.                             " ___| __ _|__  ______  __    _ ______      __|__   |__  ____ ___    _ __  _____            ",
  30.                             "|   \\/  \\|   ||   ___|\\  \\  //|   ___|    |     \\     ||    \\\\  \\  //|  ||     \\  ",
  31.                             "|     /\\     ||   ___| \\  \\// |   ___|    |  D   \\    ||  A  \\\\  \\// |  ||  D   \\  ",
  32.                             "|____/  \\____||______|  \\__/  |______|    |______/  __||__|\\__\\\\__/  |__||______/     ",
  33.                             "    |_____|                                  |_____|                                       "};
  34.  
  35.     char tableau [10] [65]={"  /\\       /\\         _______________________________________ ",
  36.                             " //\\\\_____//\\\\       /                                      ",
  37.                             "(   o      o  )     /                                           ",
  38.                             "(      ><     )    <                                            ",
  39.                             "(_           _)     \\                                          ",
  40.                             "  (         )        \\_______________________________________  ",
  41.                             "  (         )                                                   ",
  42.                             "   |   |   |                                                    ",
  43.                             "   |   |   |                                                    ",
  44.                             "  (____)____)                                                   "};
  45.  
  46.     char presentation[43]={"Ceci est un exercice pr\202sent\202 par : "};
  47.  
  48.     int decimal,Temp,affichageX=55,Cpt=0,binaire=0;
  49.     char lettre;
  50.     char choix=' ';
  51. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  52.                                     Mise en page
  53. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  54.     textcolor(LIGHTGREEN);
  55.     textbackground(BLACK);
  56.     MYwindow(1,1,100,40);
  57. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  58.                                     Affichage du Chat
  59. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  60.     for (ligne=0;ligne<10;ligne++)
  61.     {
  62.         positionX=20;
  63.             for (colonne=0;colonne<65;colonne++)
  64.             {
  65.                     gotoxy(positionX,positionY);printf("%c",tableau[ligne][colonne]);
  66.                     Sleep(5);
  67.                     positionX++;
  68.  
  69.             }
  70.             positionY++;
  71.     }
  72.     Sleep(500);
  73. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74.                                     Affichage message
  75. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  76.     for (ligne=0;ligne<43;ligne++)
  77.     {
  78.         gotoxy(ecrireX,ecrireY);printf("%c",presentation[ligne]);
  79.         Sleep(20);
  80.         ecrireX++;
  81.     }
  82.     Sleep(1250);
  83. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  84.                                     Affichage Nom
  85. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  86.    for (ligne=0;ligne<7;ligne++)
  87.     {
  88.         positionX=10;
  89.             for (colonne=0;colonne<92;colonne++)
  90.             {
  91.                     gotoxy(positionX,positionY);printf("%c",tableauNom[ligne][colonne]);
  92.                     Sleep(5);
  93.                     positionX++;
  94.  
  95.             }
  96.             positionY++;
  97.     }
  98.  
  99.  
  100. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  101.                                 Attente
  102. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  103.     Sleep(5000);
  104. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  105.                             Mise en page Exercice
  106. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  107.     MYwindow(1,1,100,50);
  108.     textbackground(WHITE); MYclrwin(1,1,100,50);
  109.     textbackground(DARKGRAY); MYclrwin(10,3,90,3);
  110.     gotoxy(20,3);textcolor(LIGHTCYAN); printf("Convertir de D\202\cimal en binaire, octal ou hexad\202\cimal");
  111.     gotoxy(82,3);textcolor(BLACK);printf("|\26||\376|");
  112.     textcolor(LIGHTRED);gotoxy(88,3);printf("|X|");
  113.     textbackground(BLACK); MYclrwin(10,4,90,58);
  114.     textcolor(LIGHTGREEN);
  115.  
  116. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  117.                             Demande de Variable et affichage
  118. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  119.  
  120.     gotoxy(30,4);printf("Quel nombre d\202\cimal voulez-vous transformer ? ");
  121.     gotoxy(49,5);scanf("%d",&decimal);
  122.  
  123.  
  124.     gotoxy(20,7);printf("Voulez-vous le transformer en binaire, en hexad\202\cimale ou en octal ?");
  125.     gotoxy(37,8);printf("Merci de rentrer votre choix : ");
  126.     gotoxy(35,9);printf("1. Pour transformer en Binaire");
  127.     gotoxy(35,10);printf("2. Pour transformer en Hexad\202\cimale");
  128.     gotoxy(35,11);printf("3. Pour transformer en Octal");
  129.  
  130.     do
  131.     {
  132.     gotoxy(49,12);scanf("%c",&choix);
  133.     }while(choix != '1' && choix != '2' && choix != '3');
  134.  
  135.     switch(choix)
  136.     {
  137. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  138.                             Transformation en binaire
  139. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  140.  
  141.         case '1':
  142.             gotoxy(35,14);printf("Vous avez choisi la transformation en binaire");
  143.             do
  144.             {
  145.                 Temp=decimal%2;
  146.                 decimal/=2;
  147.                 gotoxy(affichageX,15);printf("%d", Temp);
  148.                 affichageX--;
  149.                 Cpt++;
  150.                 if(Cpt%4==0)
  151.                 {
  152.                     affichageX--;
  153.                 }
  154.             }while (decimal!=0);
  155.  
  156.             break;
  157. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158.                             transformation en Hexa
  159. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  160.         case '2':
  161.             do
  162.             {
  163.                 gotoxy(35,14);printf("Vous avez choisi la transformation en Hexa");
  164.  
  165.                 Temp=decimal%16;
  166.                 decimal=decimal/16;
  167.  
  168.                 switch(Temp)
  169.                 {
  170.                     case 10: lettre='A';break;
  171.                     case 11: lettre='B';break;
  172.                     case 12: lettre='C';break;
  173.                     case 13: lettre='D';break;
  174.                     case 14: lettre='E';break;
  175.                     case 15: lettre='F';break;
  176.                     default : gotoxy(affichageX,15);printf("%d",Temp);break;
  177.                 }
  178.                 if(Temp>=10)
  179.                 {
  180.                     gotoxy(affichageX,15);printf("%c",lettre);
  181.                 }
  182.  
  183.                 affichageX--;
  184.             }while(decimal!=0);
  185.  
  186.             break;
  187. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  188.                             Transformation en Octal
  189. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  190.  
  191.         default:
  192.             gotoxy(35,14);printf("Vous avez choisi la transformation en Octal");
  193.             do
  194.             {
  195.                 Temp=decimal%8;
  196.                 decimal/=8;
  197.                 gotoxy(affichageX,15);printf("%d", Temp);
  198.                 affichageX--;
  199.                 Cpt++;
  200.             }while (decimal!=0);
  201.             break;
  202.     }
  203.  
  204. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  205.                                     Pause
  206. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  207.     gotoxy(11,30);textcolor(BLACK);system("pause");
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement