Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.50 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void demain(int jour, int mois, int annee)
  4. {
  5.     int tab_mois[13] = {-1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1};
  6.  
  7.     if ( ((jour > 29) && (annee % 4 == 0)) )
  8.         printf("bug");
  9.     if ( ((jour == 31) && (tab_mois[mois] == 1)) || ((jour == 30) && (tab_mois[mois] == 0))
  10.     || ((jour == 29) && (annee % 4 == 0)) || ((jour == 28) && (annee % 4 == 1))) {
  11.         jour = 1;
  12.         if (mois + 1 > 12) {
  13.             mois = 1;
  14.             annee++;
  15.         }
  16.         else
  17.             mois++;
  18.     }
  19.     else
  20.         jour++;
  21.  
  22.     printf("%d:%d:%d\n", jour, mois, annee);
  23.    
  24. }
  25.  
  26. void complete(int *a, char *b, int *c)
  27. {
  28.  
  29.     printf("nbr 1 :");
  30.     scanf("%d", a);
  31.  
  32.     printf("operation : ");
  33.     scanf(" %c", b);
  34.  
  35.     printf("nbr2 : ");
  36.     scanf(" %d", c);
  37. }
  38.  
  39. void calculatrice()
  40. {
  41.     int a = 0;
  42.     char b = 0;
  43.     int c = 0;
  44.     int resultat = 0;
  45.     char tab_operateur[4] = {'+', '*', '/', '-'};
  46.  
  47.     complete(&a, &b, &c);
  48.     for (int i = 0; tab_operateur[i]; i++) {
  49.         if (tab_operateur[i] == b) {
  50.             if (b == '+')
  51.                 resultat = a + c;
  52.             if (b == '*')
  53.                 resultat = a * c;
  54.             if (b == '/' && c != 0)
  55.                 resultat = a / c;
  56.             if (b == '-')
  57.                 resultat = a - c;
  58.         }
  59.     }
  60.     printf("resultat is : %d\n", resultat);
  61. }
  62.  
  63. int main(int argc, char *argv[])
  64. {
  65.     //demain(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
  66.     calculatrice();
  67.     return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement