➽ Problem:-

https://www.hackerrank.com/challenges/time-conversion/problem

➽ Solution:-

#include<iostream>

#include<iomanip>

using namespace std;

int main()

{

    int hour, minute, second;

    string str;

    char c;

    cin >> hour >> c >> minute >> c >> second >> str;

    if(str=="PM" && hour!=12)

        hour += 12;

    else if(str=="AM" && hour==12)

        hour = (hour+12) % 24;

   

    cout << setw(2) << setfill('0') << hour << ":"

         << setw(2) << setfill('0') << minute << ":"

         << setw(2) << setfill('0') << second << endl;

    return 0;

}