Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <vector>
  4. using namespace std;
  5. const double eps=1e-6;
  6. void level();
  7. void hm();
  8. int n;
  9. double a[100100];
  10. int main()
  11. {
  12.     int iChoice=0;
  13.     do
  14.     {
  15.     printf("1. \tPut the weight of the water here\n");
  16.     printf("2. \tSee the water dissipated\n");
  17.     printf("Choose the number:\n");
  18.     scanf("%d",&iChoice);
  19.     system("cls");
  20.     switch(iChoice)
  21.  
  22.     {
  23.     case 1:
  24.         level();
  25.         break;
  26.     case 2:
  27.         hm();
  28.         break;
  29.     }
  30.     } while (iChoice !=3);
  31.     return 0;
  32. }
  33. void level()
  34. {
  35.     double w;
  36.     printf("\nPut the water weight here: ");
  37.     scanf("%lf",&w);
  38.     a[++n]=w;
  39. }
  40. void hm()
  41. {
  42.     double Howmuch=0;
  43.     printf("\nThe amount of water you have been drinking is: ");
  44.     for (int i=1; i<n; ++i) Howmuch+=a[i]>a[i+1]?a[i]-a[i+1]:0;
  45.     printf("%.2lf (ML)\n\n",Howmuch);
  46.     int tmp;
  47.     printf("\nPress any button\n");
  48.     scanf("%d",&tmp);
  49.     //cout<<fixed<<setprecision(2)<<Howmuch<<"\n";
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement