Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.09 KB | None | 0 0
  1. //
  2. //  main.c
  3. //  Exercice 12
  4. //
  5. //  Created by Lucas Miglioranza on 26/11/15.
  6. //  Copyright (c) 2015 Lucas Miglioranza. All rights reserved.
  7. //
  8.  
  9. #include <stdio.h>
  10. #define N 10
  11.  
  12. void EncoderVecteur(int [N]);
  13. void AfficherVecteur(int [N]);
  14. int ProduitVecteurs(int c[N],int d[N]);
  15.  
  16. int main(int argc, const char * argv[])
  17. {
  18.     int Tableau[N];
  19.     int Tableau1[N];
  20.    
  21.     EncoderVecteur(Tableau);
  22.     AfficherVecteur(Tableau);
  23.     EncoderVecteur(Tableau1);
  24.    
  25.     printf("%d",ProduitVecteurs(Tableau,Tableau1));
  26.    
  27.     return 0;
  28. }
  29.  
  30. void EncoderVecteur(int e[N])
  31. {
  32.     int i;
  33.     int a;
  34.     int tmp;
  35.     for (i=0;i<N;i++)
  36.     {
  37.     printf("\nEncodage du vecteur:");
  38.     fflush(stdin);
  39.     scanf("%d",&a);
  40.     tmp = e[i];
  41.     e[i] = a;
  42.     }
  43.     return;
  44. }
  45.  
  46. void AfficherVecteur(int e[N])
  47. {
  48.     int i;
  49.     for (i=0;i<N;i++) printf("%3d", e[i]);
  50.     printf("\n");
  51.     return;
  52. }
  53.  
  54. int ProduitVecteurs(int c[N],int d[N])
  55. {
  56.     int i;
  57.     int produits = 0;
  58.    
  59.     for (i=0;i<N;i++)
  60.     {
  61.         produits = produits + c[1]*d[1];
  62.     }
  63.     return (produits);
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement