![estefaniapenalo](/avatars/20825.jpg)
estefaniapenalo
28.10.2019 •
Computers and Technology
Fill in the blank
anne travels extensively, and visits many countries. she wants to write about her journeys and voyages on the internet. what internet service will best suit her needs?
anne can write about her travel experiences in a .
Solved
Show answers
More tips
- S Style and Beauty How to Sew a Balloon Skirt: Detailed Tutorial and Tips on Choosing the Right Fabric...
- P Philosophy Agnosticism: Opinion or Belief?...
- S Style and Beauty How to choose the best mascara for your eyelashes...
- F Food and Cooking Discover Delicious Recipes You Can Make with Ground Meat...
- C Computers and Internet Google Search Tips and Tricks: Everything You Need to Know...
- S Science and Technology Why is there no gravity on other planets?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
- L Leisure and Entertainment How to Make a Paper Boat in Simple Steps...
- T Travel and tourism Maldives Adventures: What is the Best Season to Visit the Luxurious Beaches?...
- H Health and Medicine Kinesiology: What is it and How Does it Work?...
Answers on questions: Computers and Technology
- C Computers and Technology Whos the smartest person in the world?...
- C Computers and Technology Aseller buys and item from a manufacturer for 9,500...
- M Mathematics What is the value of x?...
- H History Simplify (5^-2)^4 Please...
- M Mathematics Find the area of a circle with a 2 cm diameter. Round your answer to the nearest hundredth....
- E English 3. Which statement describes Mary s motivation for covering up her crime? (Paragraphs 46-48) O A She wants to protect her unborn child. OB She thinks she did nothing wrong....
- M Mathematics What is the sum or difference? 2y^5-4y^5...
- S Social Studies What geographic feature on the map helped rome trade with surrounding areas...
- C Chemistry In a lava lamp, a waxy substance rises and falls repeatedly. What causes the waxy substance to rise? A) The waxy substance is cold. B) The waxy substance is warm. C) The...
- B Business The balance sheet of Morgan and Rockwell was as follows immediately prior to the partnership s liquidation: cash, $25,900; other assets, $147,000; liabilities, $38,800;...
Ответ:
Ответ:
Code in C++::
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
string timeConversion(string s){
/**
* Following two strings are declared named d and c respectively.
* String c will be storing the converted format time and we will return
* c as the answer.
*/
string d,c="";
/**
* String d stores "PM" or "AM"
*/
d=s.substr(8,2);
/**
* An integer named hr is declared below and it stores
* the hh part of string hh:mm:ssPM in integer format.
*/
int hr=atoi(s.substr(0,2).c_str());
if(hr==12 && d=="AM"){
/**
* Now suppose hr is 12 and its AM then we know that it's
* midnight and so hr must be 0.
*/
hr=0;
}
if(d=="PM" && hr!=12){
/**
* Suppose d is "PM" and hr is not 12 then we add 12 into hr.
*/
hr+=12;
}
if(hr<10){
/**
* Now suppose hr is less then 10 then we know that in final answer
* if hr is 7 then we need "07".
* So if hr < 10 then we add extra 0 at start of c string.
*/
c+="0";
}
/**
* Now we convert hr back to string using stringstream.
* A variable named hour is declared and we convert hr to string as follows.
*/
stringstream hour;
hour<<hr;
/**
* Finally we update the c string as required and return it at the end.
*/
c=c+hour.str()+s.substr(2,6);
return c;
}
int main(){
/**
* A string named s is declared and using cin we scan the string.
*/
string s;
cin>>s;
/**
* Below we call the function and pass string s as parameter.
* Whatever function returns, it is printed.
*/
cout<<timeConversion(s)<<endl;
return 0;
}
Explanation:
see thees attached