Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.11 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3.  
  4. void verifierTableau(int tableau1[],int tableau2[],int tailleTableau);
  5.  
  6. int main (void)
  7. {
  8. int tailleChoix;
  9. printf("Combien de case pour le tableau ?\n");
  10. scanf("%d",&tailleChoix);
  11.  
  12. int tableau1[tailleChoix];
  13. int tableau2[tailleChoix];
  14.  
  15. printf("\n Saisie du premier tableau : \n\n");
  16.  
  17. for (int k=0;k<tailleChoix;k++)
  18. {
  19. printf("Rentrez la case numero %d du tableau : ",k+1);
  20. scanf("%d",&tableau1[k]);
  21. }
  22.  
  23. printf("\n Saisie du deuxieme tableau : \n\n");
  24.  
  25. for (int l=0;l<tailleChoix;l++)
  26. {
  27. printf("Rentrez la case numero %d du tableau : ",l+1);
  28. scanf("%d",&tableau2[l]);
  29. }
  30.  
  31. verifierTableau(tableau1,tableau2,tailleChoix);
  32. }
  33.  
  34.  
  35.  
  36. void verifierTableau(int tableau1[], int tableau2[], int tailleTableau)
  37. {
  38.     int verif=0;
  39.     bool erreur=false;
  40.     int x=0;
  41.    
  42.     while (erreur==false && x<tailleTableau)
  43.     {
  44.         int j=tailleTableau-(x+1);
  45.         if (tableau1[x]!=tableau2[j])
  46.         {
  47.           erreur=true;
  48.         }
  49.         x++;
  50.     }
  51.     erreur?printf("Les tableaux ne sont pas symetriques"):printf("Les tableaux sont symétriques");
  52.    
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement