Subversion Repositories wimsdev

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
795 bpr 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(argc,argv)
25
        int argc;
26
        char *argv[];
27
{
28
 
29
        int tab[51];
30
 
31
        int i,q1,niveau, TAILLE, val, max, compteur;
32
        char sens_boucle1[10];
33
        char valeur_boucle1[10];
34
        char parite[10];
35
 
36
        sscanf(argv[2],"%d",&niveau);
37
        sscanf(argv[3],"%d",&TAILLE);
38
        strcpy(sens_boucle1,argv[4]);
39
        strcpy(valeur_boucle1,argv[5]);
40
        strcpy(parite,argv[6]);
41
        sscanf(argv[7],"%d",&val);
42
        sscanf(argv[8],"%d",&max);
43
        sscanf(argv[9],"%d",&q1);
44
        compteur =0;
45
 
46
        if (strcmp(sens_boucle1,valeur_boucle1)==0)
47
        {
48
                for (i=0;i<TAILLE ; i++)
49
                {
50
                        tab[i] = i;
51
                        compteur++;
52
                }
53
        }
54
        else
55
        {
56
                for (i=0;i<TAILLE ; i++)
57
                {
58
                        tab[i] = TAILLE-i-1;
59
                        compteur++;
60
                }
61
        }
62
 
63
        if(niveau>2)
64
        {
65
                for (i=1;i<TAILLE ; i++)
66
                {
67
                        if (tab[i] > max)
68
                        {
69
                                tab[i]=tab[i-1];
70
                        }
71
                        else if (i> max)
72
                        {
73
                                tab[i]=tab[i]+1;
74
                        }
75
                        compteur++;
76
 
77
                }
78
        }
79
 
80
        if(niveau>1)
81
        {
82
                if (strcmp(parite,"pair")==0)
83
                {
84
                        for (i=0; 2*i<TAILLE ;i=i+1)
85
                        {
86
                                tab[2*i]=tab[2*i]+val;
87
                                compteur++;
88
                        }
89
                }
90
                else
91
                {
92
                        for (i=0; 2*i+1<TAILLE ;i=i+1)
93
                        {
94
                                tab[2*i+1]=tab[2*i+1]+val;
95
                                compteur++;
96
                        }
97
                }
98
        }
99
 
100
        if (niveau<4)
101
                compteur=0;
102
        printf("%d,%d,%d\n",tab[q1], tab[q1+1], compteur);
103
 
104
 
105
        return 0;
106
 
107
}
108
 
109