Anik_Akash

1217_Getline Two - Fruits_uri

Jul 8th, 2020
78
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //thanks God For Every Thing!
  2. //contest link:
  3. #include<bits/stdc++.h>
  4. #include<stdio.h>
  5. #include<string.h>
  6. #include<math.h>
  7. #define pi                      acose(-1)
  8. #define rep(i,x)                for(int i=0; i<(x); i++)
  9. #define rep1(i,x)               for(int i=1; i<=(x); i++)
  10.  
  11. typedef long long int           ll;
  12. typedef double                  dl;
  13. using namespace std;
  14.  
  15.  
  16.  
  17. int main()
  18. {
  19.     int n, i, j, frt=1;
  20.     double cost;
  21.     char s[1500];
  22.     cin>>n;
  23.     int day[n];
  24.     double total_cost=0, day_kg=0;
  25.     for(i=1; i<=n; i++)
  26.     {
  27.         cin>>cost;
  28.         cin.ignore();
  29.         total_cost = total_cost+cost;
  30.  
  31.         scanf("%[^\n]",s);
  32.         int ln;
  33.         ln = strlen(s);
  34.         for(j=0; j<ln; j++)
  35.         {
  36.             if(s[j]==' ')
  37.             {
  38.                 frt++;
  39.             }
  40.         }
  41.  
  42.         day [i]=frt;
  43.         day_kg=frt+day_kg;
  44.         frt=1;
  45.     }
  46.     for(i=1; i<=n; i++){
  47.         printf("day %d: %d kg\n", i, day[i]);
  48.     }
  49.    /* printf("%.2lf kg by day\n", day_kg/n);
  50.     printf("R$ %.2lf by day\n", total_cost/n);*/
  51.     cout<<fixed<<setprecision(2)<< day_kg/n<< " kg by day"<<endl;
  52.     cout<<fixed<<setprecision(2)<<"R$ "<<total_cost/n<<" by day"<<endl;
  53.     return 0;
  54. }
RAW Paste Data