Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <vector>
- using namespace std;
- const double eps=1e-6;
- void level();
- void hm();
- int n;
- double a[100100];
- int main()
- {
- int iChoice=0;
- do
- {
- printf("1. \tPut the weight of the water here\n");
- printf("2. \tSee the water dissipated\n");
- printf("Choose the number:\n");
- scanf("%d",&iChoice);
- system("cls");
- switch(iChoice)
- {
- case 1:
- level();
- break;
- case 2:
- hm();
- break;
- }
- } while (iChoice !=3);
- return 0;
- }
- void level()
- {
- double w;
- printf("\nPut the water weight here: ");
- scanf("%lf",&w);
- a[++n]=w;
- }
- void hm()
- {
- double Howmuch=0;
- printf("\nThe amount of water you have been drinking is: ");
- for (int i=1; i<n; ++i) Howmuch+=a[i]>a[i+1]?a[i]-a[i+1]:0;
- printf("%.2lf (ML)\n\n",Howmuch);
- int tmp;
- printf("\nPress any button\n");
- scanf("%d",&tmp);
- //cout<<fixed<<setprecision(2)<<Howmuch<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement