Sunday, 6 November 2016

Hacker Rank Solution Program In C++ For " Print Pretty "

Problem :-Your manager gave you a text file with many lines of numbers to format and print. For each row of 3 space-separated doubles, format and print the numbers using the specifications in the Output Format section below.

Input Format

The first line contains an integer, T , the number of test cases.
Each of the T subsequent lines describes a test case as 3 space-separated floating-point numbers: A , B , and , C respectively.

Solution :-Copy The Colored Part And Paste it Into HackerRank Terminal And Click On Submit Button

#include <iostream>

#include <iomanip>
using namespace std;

int main() {
int T; cin >> T;
cout << setiosflags(ios::uppercase);
cout << setw(0xf) << internal;
while(T--) {
double A; cin >> A;
double B; cin >> B;
double C; cin >> C;

/* Enter your code here */   
cout << resetiosflags(ios::uppercase|ios::scientific);
cout << std::setiosflags (ios::left|ios::fixed);
cout << setw(0) << std::hex;
cout << std::setiosflags (ios::showbase);
cout << (unsigned long)A << std::endl;

cout << resetiosflags(ios::showbase);

cout << setw(0xf) << setfill('_')<< std::dec ;
cout << setiosflags (ios::showpos) << setprecision(2);
cout  << B << endl;

cout << resetiosflags(ios::fixed|ios::showpos);

cout << setiosflags (ios::scientific | ios::uppercase) << setprecision(9);
cout << C << std::endl;

/*code ends here*/

}
return 0;
}

Output :-

1.Compilation With Custom Input

 Hacker Rank Solution Program In C++ For " Print Pretty "

2.All Testcase's 

 Hacker Rank Solution Program In C++ For " Print Pretty "

No comments:
Write comments

Recommended Posts × +