bouchnina

V3 j2 2013 - Langage C

Jul 19th, 2013
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. /// Exercice 2
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. void Remplacer(int t[],int taille){
  6.     int i,j;
  7.         for(i=0;i<taille;i++){
  8.             for(j=i;j<taille;j++){
  9.                 if(t[j]<t[i]) t[j]=t[i];
  10.             }
  11.         }
  12.     for(i=0;i<taille;i++)
  13.         printf("%d ",t[i]);
  14. }
  15.  
  16. ///////////////////////////////////////////////////////
  17.  
  18. //Ex 1
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. double fonctionCalcul(int n){
  22.     double t[20];
  23.     int i;
  24.     t[0]=1,t[1]=1;
  25.     for(i=2;i<=n;i++){
  26.         t[i]=t[i-1]+(t[i-2]/2);
  27.     }
  28.     return t[n];
  29. }
  30. int main()
  31. {
  32.     double tab[10];
  33.     int i;
  34.     tab[0]=1,tab[1]=1;
  35.     for(i=2;i<10;i++){
  36.         tab[i]=fonctionCalcul(i);
  37.     }
  38.     for(i=0;i<10;i++)
  39.         printf("%.2f ",tab[i]);
  40.     printf("\n\n");
  41.     system("pause");
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment