Wednesday, May 3, 2017

URI 1540 Solution Energy Planning - in C++ | Ad Hoc

URI 1540 Solution Energy Planning - in C++ | Ad Hoc


URI Online Judge Solution  | Ad Hoc
URI Main Problem Link - Energy Planning  https://www.urionlinejudge.com.br/judge/en/problems/view/1540

Problem Name: URI Problem Energy Planning
Problem Number : URI Problem 1540  Solution
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus

URI Solution 1540   Code in CPP:


#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
    int n;
    double a, b, c, d, m;
    
    cin >> n;

    while(n--)
    {
        cin >> a >> b >> c >> d;
        char buff[ 50 ];

        m = ((d - b)/(c - a));
        sprintf(buff, "%lf", m);
        
        for(int j = 0; j < 50; j++) 
        {    
            if(buff[j] != '.') {
                cout << buff[j];
            }else {
                cout << ",";
                
                for(int k = j + 1; k < j + 3; k++)
                    cout << buff[k];
                cout << "\n";
                break;
            }
        } 
    }
    
    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.