Subversion Repositories wimsdev

Rev

Rev 795 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4.  
  5. /* Prog C qui fournit les reponses a l'exercice .oef .
  6. L'executable doit s'appeler tab1d.o et etre place dans
  7. ~/wims/other/bin
  8. Ce prog doit etre lance par le script /wims/public_html/bin/sh_bioinfo
  9. */
  10.  
  11. /* Entrees :
  12.         argv[1]= nom du programme ()
  13.         argv[2]= \niveau
  14.         argv[3]= \TAILLE
  15.         argv[4]= \sens_boucle1
  16.         argv[5]= \valeur_boucle1
  17.         argv[6]= \parite
  18.         argv[7]= \val
  19.         argv[8]= \max
  20.         argv[9]= \q1
  21.  
  22. */
  23.  
  24. int main(int argc, char *argv[])
  25. {
  26.         int tab[51];
  27.  
  28.         int i,q1,niveau, TAILLE, val, max, compteur;
  29.         char sens_boucle1[10];
  30.         char valeur_boucle1[10];
  31.         char parite[10];
  32.  
  33.         sscanf(argv[2],"%d",&niveau);
  34.         sscanf(argv[3],"%d",&TAILLE);
  35.         strcpy(sens_boucle1,argv[4]);
  36.         strcpy(valeur_boucle1,argv[5]);
  37.         strcpy(parite,argv[6]);
  38.         sscanf(argv[7],"%d",&val);
  39.         sscanf(argv[8],"%d",&max);
  40.         sscanf(argv[9],"%d",&q1);
  41.         compteur =0;
  42.  
  43.         if (strcmp(sens_boucle1,valeur_boucle1)==0)
  44.         {
  45.                 for (i=0;i<TAILLE ; i++)
  46.                 {
  47.                         tab[i] = i;
  48.                         compteur++;
  49.                 }
  50.         }
  51.         else
  52.         {
  53.                 for (i=0;i<TAILLE ; i++)
  54.                 {
  55.                         tab[i] = TAILLE-i-1;
  56.                         compteur++;
  57.                 }
  58.         }
  59.  
  60.         if(niveau>2)
  61.         {
  62.                 for (i=1;i<TAILLE ; i++)
  63.                 {
  64.                         if (tab[i] > max)
  65.                         {
  66.                                 tab[i]=tab[i-1];
  67.                         }
  68.                         else if (i> max)
  69.                         {
  70.                                 tab[i]=tab[i]+1;
  71.                         }
  72.                         compteur++;
  73.  
  74.                 }
  75.         }
  76.  
  77.         if(niveau>1)
  78.         {
  79.                 if (strcmp(parite,"pair")==0)
  80.                 {
  81.                         for (i=0; 2*i<TAILLE ;i=i+1)
  82.                         {
  83.                                 tab[2*i]=tab[2*i]+val;
  84.                                 compteur++;
  85.                         }
  86.                 }
  87.                 else
  88.                 {
  89.                         for (i=0; 2*i+1<TAILLE ;i=i+1)
  90.                         {
  91.                                 tab[2*i+1]=tab[2*i+1]+val;
  92.                                 compteur++;
  93.                         }
  94.                 }
  95.         }
  96.  
  97.         if (niveau<4)
  98.                 compteur=0;
  99.         printf("%d,%d,%d\n",tab[q1], tab[q1+1], compteur);
  100.  
  101.  
  102.         return 0;
  103.  
  104. }
  105.  
  106.  
  107.