Tableau interactif et convivial

Description

Ces programmes permettent de saisir des réels dans un tableau, de calculer la somme et la moyenne des éléments saisi. Ils ont été conçu avec turbo c sou windows xp.J'ai ajouté quelques animations pour pigmenté la programme.J'attends vos critiques
Merci

Source / Exemple :


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#define vrai 1
#define faux 0
//definition des variables globales
float max,min,s,m;
float note[5];
double listreel[5];
char * chain = " M E R C I  E T  A U R E V O I R ";
 char * chaine1 = " CISSE Baba Mohamed";
 char * chaine2 = " www.cisconsulting.com";
 char * chaine3 = " cissebaban@gmail.com";
 char * chaine4 = " +225 47 53 14 74";
 char * chaine5 = " 1.5 Copyright 2013";
 int a,b,c,d,e,p;
int cpt=0;//nombres d'elements inser dans le tableau
int estplein()
{
return (cpt==5);
}

int verifnombre(char *s)//verifie si une chaine de caractere est numerique
  {
    int j;
     int res=vrai;

    for(j=0;j<strlen(s); j++){
      if(!isdigit(s[j])&& s[j]!='.'){
	  res=faux;

       break;}}
	return res;
  }

void saisie()
{
int i;
double val;
char buffer[81];
textcolor(WHITE);
 for(i=1;i<cpt;i++){
      gotoxy(3,5);
cprintf(" Veuillez entrer les elements du tableau: ");
gotoxy(45,4+i);
cscanf("%.3lf",&listreel[i]);
gotoxy(22,28);
textcolor(CYAN);
cprintf(" Tapez f pour arreter la saisie\n");}
do
{
gets(buffer);
 if(strcmpi(buffer,"f")==0)
 {
     break;
     }
 else
  {
    if(verifnombre(buffer))
    {
       if(!estplein())
	{
	 val=atof(buffer);
       listreel[cpt]=val;
       cpt++;
	}
       else
     {
     textcolor(RED+BLINK);
gotoxy(22,28);
      cprintf("impossible d'ajouter, le tableau est plein");
      delay(5000);
      break;
     }
    }
 else
 {
 textcolor(RED+BLINK);
gotoxy(22,28);
  cprintf(" Format incorrect,veuillez resaisir");
  delay(5000);
  }
  }
}
while(strcmpi(buffer,"f")==0);
}

double maximum()
  {
    int i;
    double max=listreel[0];
     for(i=1;i<cpt;i++)
       if( max<listreel[i])
	  max=listreel[i];
	 return max;
   }

double minimum()
{
    int i;
    double min=listreel[0];
     for(i=1;i<cpt;i++)
       if( min>listreel[i])
	  min=listreel[i];
	 return min;
}

double somme()
{
  double s=0;
  int i;
   for(i=0;i<cpt;i++)
      s=s+listreel[i];
      return s;
}

double moyenne()
{
return(somme()/cpt);
}

void affichage()
{
  int i;
  textcolor(WHITE);
gotoxy(5,3);
   cprintf("La valeur de la moyenne: %.3lf\n",moyenne());
   for(i=0;i<cpt;i++)
    if (listreel[i]>moyenne())
    textcolor(WHITE);
gotoxy(5,5);
       cprintf("Liste des valeurs superieures &#8230; la moyenne: listreel[%d]=%.3lf\n",i,listreel[i]);

}

 int estvide()
{
return (cpt==0);
}

void menu()
{
char log[5];
char pass[5];
int choix,i;
char ch,touche;
int j;
char*chaine="²";
textbackground(BLACK);
clrscr();
gotoxy(3,23);
textcolor(WHITE);
cprintf("PASSWORD :");
gotoxy(15,18);
textcolor(WHITE);
cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿");
gotoxy(15,19);
cprintf("³                     ³");
gotoxy(15,20);
cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ");
gotoxy(15,22);
textcolor(WHITE);
cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿");
gotoxy(15,23);
cprintf("³                     ³");
gotoxy(15,24);
cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ");
gotoxy(3,19);
cprintf("LOGIN :");
gotoxy(17,19);
cprintf("");
cscanf("%s",log[5]);
getch();
gotoxy(3,23);
cprintf("PASSWORD :");
gotoxy(17,23);
cprintf("");
while(1)
    {
    if(i<0)
	 i=0;
    ch=getch();

    if(ch==13)
	break;

    if(ch==8) /*ASCII value of BACKSPACE*/
	{
	putch('b');
	putch(NULL);
	putch('b');
	i--;
	continue;
	}

   pass[i++]=ch;
   ch='*';
   putch(ch);
   }
textbackground(BLACK);
clrscr();
gotoxy(20,18);
textcolor(WHITE);
cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿");
gotoxy(20,19);
cprintf("³                                 ³");
gotoxy(20,20);
cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ");
for (j=0;j<33;j++){
    gotoxy(j+21,19);
    textcolor(4);
    cprintf("%s",chaine);
    gotoxy(15,23);
    textcolor(GREEN);
    cprintf("Veuillez patientez SVP: chargement en cours...");

    delay(250);
   }
do
{
 textbackground(BLUE);
clrscr();
gotoxy(27,5);
textcolor(WHITE);
cprintf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
gotoxy(27,6);
cprintf("º                       º");
gotoxy(27,7);
cprintf("º                       º");
gotoxy(27,8);
cprintf("º                       º");
gotoxy(27,9);
cprintf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ&#188;");
gotoxy(30,7);
textcolor(GREEN);
cprintf(" PROGRAMME TABLEAU ");
textcolor(WHITE);
gotoxy(25,11);
cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿");
gotoxy(25,12);
cprintf("³                           ³");
gotoxy(25,13);
cprintf("³                           ³");
gotoxy(25,14);
cprintf("³                           ³");
gotoxy(25,15);
cprintf("³                           ³");
gotoxy(25,16);
cprintf("³                           ³");
gotoxy(25,17);
cprintf("³                           ³");
gotoxy(25,18);
cprintf("³                           ³");
gotoxy(25,19);
cprintf("³                           ³");
gotoxy(25,20);
cprintf("³                           ³");
gotoxy(25,21);
cprintf("³                           ³");
gotoxy(25,22);
cprintf("³                           ³");
gotoxy(25,23);
cprintf("³                           ³");
gotoxy(25,24);
cprintf("³                           ³");
gotoxy(25,25);
cprintf("³                           ³");
gotoxy(25,26);
cprintf("³                           ³");
gotoxy(25,27);
cprintf("³                           ³");
gotoxy(25,28);
cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ");
gotoxy(35,12);
textcolor(RED);
cprintf("M E N U ");
gotoxy(26,13);cprintf("---------------------------");
textcolor(YELLOW);
gotoxy(28,15);
cprintf("1- SAISIE DES ELEMENTS\n");
gotoxy(28,17);
cprintf("2: MAXIMUM DES ELEMENTS\n");
gotoxy(28,19);
cprintf("3: MINIMUN DES ELEMENTS\n");
gotoxy(28,21);
cprintf("4: SOMME DES ELEMENTS\n");
gotoxy(28,23);
cprintf("5: MOYENNE DES ELEMENTS\n");
gotoxy(28,25);
cprintf("6: QUITTER LE PROGRAMME\n" );
gotoxy(5,30);
textcolor(CYAN);
printf("Entrez votre choix:");
scanf("%d",&choix);
 switch(choix)
  {
    case 1:
     clrscr();//efface l'ecran
      for (i=0;i<5;i++){
   textcolor(WHITE);
cprintf("\n Quelle est la note num&#8218;ro %d: ",i+1);
scanf("%f",&note[i]);
	   }
       break;
    case 2:
    clrscr();
      max=note[0];
     for(i=0;i<5;i++)
       if( max<=note[i]){
	  max=note[i];
	 gotoxy(5,5);   textcolor(WHITE);
cprintf("\n Le maximun des notes est: %f",max); }

	   textcolor(CYAN);
gotoxy(22,28);
       cprintf("Tapez une touche pour revenir au menu general");
       getch();clrscr();
	break;
       case 3:
	  clrscr();
      min=note[0];
     for(i=0;i<5;i++)
       if( min>=note[i]){
	  min=note[i];
	 gotoxy(5,5);   textcolor(WHITE);
cprintf("\n Le minimun des notes est: %f",min); }

	   textcolor(CYAN);
gotoxy(22,28);
       cprintf("Tapez une touche pour revenir au menu general");
       getch();clrscr();
	break;
	case 4:
		clrscr();
	   s=0;
for (i=0;i<5;i++)
 s=s+note[i]; gotoxy(5,5); textcolor(WHITE);
cprintf("\n La somme des notes est: %f",s);

	   textcolor(CYAN);
gotoxy(22,28);
       cprintf("Tapez une touche pour revenir au menu general");
       getch();clrscr();
	break;
	case 5:
	  clrscr();
	m=0;
for (i=0;i<5;i++)
m=m+note[i];
m=m/5; gotoxy(5,5); textcolor(WHITE);
cprintf("\n La moyenne est: %.2f",m);
 textcolor(CYAN);
gotoxy(22,28);
       cprintf("Tapez une touche pour revenir au menu general");
       getch();clrscr();
	break;
	case 6:
     clrscr();
     textcolor(4);
gotoxy(60,2);
cprintf("²²²²");
gotoxy(60,2);
cprintf("²²²²");
gotoxy(60,3);
cprintf("²²²²");
gotoxy(60,4);
cprintf("²²²²");
gotoxy(60,5);
cprintf("²²²²");
gotoxy(60,6);
cprintf("²²²²");
textcolor(WHITE);
gotoxy(64,2);
cprintf("²²²²");
gotoxy(64,2);
cprintf("²²²²");
gotoxy(64,3);
cprintf("²²²²");
gotoxy(64,4);
cprintf("²²²²");
gotoxy(64,5);
cprintf("²²²²");
gotoxy(64,6);
cprintf("²²²²");
textcolor(GREEN);
gotoxy(68,2);
cprintf("²²²²");
gotoxy(68,2);
cprintf("²²²²");
gotoxy(68,3);
cprintf("²²²²");
gotoxy(68,4);
cprintf("²²²²");
gotoxy(68,5);
cprintf("²²²²");
gotoxy(68,6);
cprintf("²²²²");
gotoxy(53,8);
textcolor(WHITE);
cprintf("Republique de C&#8220;te d'Ivoire");
gotoxy(53,9);
textcolor(4);
cprintf("Union -");
gotoxy(61,9);
textcolor(WHITE);
cprintf("Dicipline -");
gotoxy(73,9);
textcolor(GREEN);
cprintf("Travail");
gotoxy(16,24);
textcolor(YELLOW);
cprintf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
gotoxy(16,25);
cprintf("º                                             º");
gotoxy(16,26);
cprintf("º                                             º");
gotoxy(16,27);
cprintf("º                                             º");
gotoxy(16,28);
cprintf("º                                             º");
gotoxy(16,29);
cprintf("º                                             º");
gotoxy(16,30);
cprintf("º                                             º");
gotoxy(16,31);
cprintf("º                                             º");
gotoxy(16,32);
cprintf("º                                             º");
gotoxy(16,33);
cprintf("º                                             º");
gotoxy(16,34);
cprintf("º                                             º");
gotoxy(16,35);
cprintf("º                                             º");
gotoxy(16,36);
cprintf("º                                             º");
gotoxy(16,37);
cprintf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ&#188;");
textcolor(CYAN);
gotoxy(30,2);
cprintf("        .::::        ");
gotoxy(30,3);
cprintf("       :::::::       ");
gotoxy(30,4);
cprintf("      :::::::::      ");
gotoxy(30,5);
cprintf("     :::::.::::.     ");
gotoxy(30,6);
cprintf("     :::::.:::::     ");
gotoxy(30,7);
cprintf("     .::::.:::::     ");
gotoxy(30,8);
cprintf("     .::::::H:::     ");
gotoxy(30,9);
cprintf("     .HH:H:H::::     ");
gotoxy(30,10);
cprintf("     .::::::::::     ");
gotoxy(30,11);
cprintf("     ::::H::.:::     ");
gotoxy(30,12);
cprintf("      :::::::::      ");
gotoxy(30,13);
cprintf("      :::HHH:::      ");
gotoxy(30,14);
cprintf("      .H:HH::::      ");
gotoxy(30,15);
cprintf("      HHH:::HH:H     ");
gotoxy(30,16);
cprintf("   HHH. HHHHHH HHH   ");
gotoxy(30,17);
cprintf(" HHHHH:  :H:  .HHHHH ");
gotoxy(30,18);
cprintf(" HHHHHH   H   .HHHHH ");
gotoxy(30,19);
cprintf(" HHHHHH  :.:  HHHHHH ");
gotoxy(30,20);
cprintf(" HHHHHH  :..  HHHHHH ");
gotoxy(30,21);
cprintf(" HHHHHH   .   HHHHHH ");
gotoxy(30,22);
cprintf(" HHHHHH  ..   :HH:HH ");
textcolor(WHITE);
gotoxy(22,26);cprintf("CONCEPTEUR : ");

gotoxy(22,28);cprintf("  SITE WEB : ");

gotoxy(22,30);cprintf("    E-MAIL : ");
gotoxy(22,32);cprintf("   CONTACT : ");
gotoxy(22,34);cprintf("   VERSION : ");
for (a=0;a<strlen(chaine1);a++){
    gotoxy(a+34,26);
    printf("%c",chaine1[a]);
    delay(80);
   }
for (b=0;b<strlen(chaine2);b++){
    gotoxy(b+34,28);
    printf("%c",chaine2[b]);
    delay(80);
   }
for (c=0;c<strlen(chaine3);c++){
    gotoxy(c+34,30);
    printf("%c",chaine3[c]);
    delay(80);
   }
for (d=0;d<strlen(chaine4);d++){
    gotoxy(d+34,32);
    printf("%c",chaine4[d]);
    delay(80);
   }
for (e=0;e<strlen(chaine5);e++){
    gotoxy(e+34,34);
    printf("%c",chaine5[e]);
    delay(80);
   }
 for (i=1;i<=80;i++){
    gotoxy(i,40);
    printf("%s",chain);
    delay(100);
     if (i==80){
   p=p++;
   i=1;
   exit(p==10);}
   }

delay(7000);
default:clrscr();
textcolor(RED+BLINK);
gotoxy(22,28);
	 cprintf("Erreur sur la saisie, veuillez saisir le bon chiffre");
	 delay(5000);
	gotoxy(5,32);
textcolor(CYAN);
printf("Entrez votre choix:");
}
}
while(choix !=6);
}

//corps du programme C

int main(void)
{
   menu();
  return 0;
}

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.