Bonjour,

j'ai un petit problème. J'ai un code où il y a trois options en fonctions de l'argument choisi. De façon indépendante elles marchent mais une fois mise ensemble cela ne m'affiche plus rien, le programme ne retrant pas mes conditions. Si quelqu'un pouvait me dire d'où ça vient.

Merci d'avance.

Mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <stdio.h>                                         
#include <stdlib.h>
#include <time.h>
 
int    Random (int _iMin, int _iMax)
{
  return (_iMin + (rand () % (_iMax-_iMin+1)));
}
 
int    main(int argc, char **argv)
{
  int resultats_a[20];
  int resultats_b[20];
  int i;
  int j;
  int iRandom;
  int results;
  int total;
  int Pa;
  int temp;
 
  i = 0;
  j = 0;
  srand(time(NULL));
  if(*argv[1] == 1)
    {
      printf("Vecteur A : ");
      while(i <= *argv[2])
    {
      iRandom = Random (-9, 9);
      resultats_a[j] = iRandom;
      printf(" %d", iRandom);
      j++;
      i++;
    }
      i = 0;
      j = 0;
      printf("\nVecteur B : ");
      while(i <= *argv[2])
    {
      iRandom = Random (-9, 9);
      resultats_b[j] = iRandom;
      printf(" %d", iRandom);
      j++;
      i++;
    }
      printf("\n");
      i = 0;
      j = 0;
      if(i == 0)
    printf("Valeur de A + B : ");
      while(i <= 6)
    {
      results = resultats_a[i] + resultats_b[j];
      printf(" %d", results);
      i++;
      j++;
    }
    }
  printf("\n");
  if(*argv[1] == 2)
    {
      i = 0;
      j = 0;
      srand(time(NULL));
      printf("Nombre P : ");
      scanf("%d", Pa);
      printf("Vecteur A : ");
      while(i <= *argv[2])
    {
      iRandom = Random (-9, 9);
      resultats_a[j] = iRandom;
      printf(" %d", iRandom);
      j++;
      i++;
    }
      i = 0;
      j = 0;
      if(i == 0)
    printf("Vecteur p.A: ");
      while(i <= *argv[2])
    {
      results = resultats_a[i] * Pa ;
      printf(" %d", results);
      i++;
      j++;
    }     
    }
  if(*argv[1] == 3)
    {
      i = 0;
      j = 0;
      srand(time(NULL));
      printf("Vecteur A : ");
      while(i <= *argv[2])
    {
          iRandom = Random (-9, 9);
          resultats_a[j] = iRandom;
          printf(" %d", iRandom);
          j++;
          i++;
        }
      i = 0;
      j = 0;
      printf("\nVecteur B : ");
      while(i <= *argv[2])
        {
          iRandom = Random (-9, 9);
          resultats_b[j] = iRandom;
          printf(" %d", iRandom);
          j++;
          i++;
        }
      i = 0;
      j = 0;
      temp = 0;
      while(resultats_a[i] & resultats_b[j])
    {
      total = resultats_a[i] * resultats_b[j];
      temp = temp + total;
      i++;
      j++;
    }
      printf("\nProduit scalaire (A,B) : %d", temp);
    }    
}