Joao_Joao

Getline Two - C++

May 14th, 2022 (edited)
771
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define f(i, s, f) for(int i = s; i < f; ++i)
  5. #define r(x, ns) for(auto& x : ns)
  6.  
  7. int main() {
  8.   int n; cin>>n;
  9.   string p;
  10.   double kg, rs, kgs = 0, rss = 0;
  11.   f(i,0,n) {
  12.     cin>>rs;
  13.     getline(cin, p);
  14.     getline(cin, p);
  15.     kg = 1;
  16.     r(l, p) kg += (l == ' ');
  17.     printf("day %d: %.0lf kg\n", i+1, kg);
  18.     rss += rs, kgs += kg;
  19.   }
  20.   printf("%.2lf kg by day\nR$ %.2lf by day\n", kgs / n, rss / n);
  21. }
  22.  
RAW Paste Data Copied