Monday, May 1, 2017

URI Solution 1217 Getline Two - Fruits - Solution in C++ | Ad Hoc

URI Solution 1217 Getline Two - Fruits - Solution in C++ | Ad Hoc


URI Online Judge Solution Getline Two - Fruits | Ad Hoc


Problem Name: URI Problem Getline Two - Fruits
Problem Number : URI - 1217
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus

URI Solution 1217 Code in CPP:

#include <stdio.h>
#include <iostream>
#include <sstream>
using namespace std;

int main(){
    int n, day = 1, tmp, kgDay;
    double m, tot, kgs;

    scanf("%d", &n);
    tmp = n;

    while (n > 0) 
    {
        scanf("%lf", &m);
        tot += m;
        string s, t;

        do {
            getline(cin, s);
        } while (s.size() == 0);
        
        stringstream ss;
        ss << s; kgDay = 0;

        while (ss >> t)
            kgDay++;
        
        printf("day %d: %d kg\n", day, kgDay);
        kgs += kgDay;
        n--; day++;
    }

    if(tmp != 0)
        printf("%.2lf kg by day\nR$ %.2lf by day\n", kgs/tmp, tot/tmp);
 
 return 0; 
}

No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.